Device Read API

Application is able to directly read current device attributes.

Device Attribute API

Libre_DeviceGetAttribute(id, cluster, attrId)

Get single attribute of a device.

Parameters:

  • id - Integer, internal device ID.
  • cluster - Integer, the cluster of attribute.
  • attrId - Integer, the ID of attribute.

Returns:

  • The value of attribute; or nil if the attribute is not available or not supported.

Libre_DeviceGetAttributes(id, cluster)

Get all attributes of given cluster ofa device.

Parameters:

  • id - Integer, internal device ID.
  • cluster - Integer, the cluster of attribute.

Returns:

  • A key/value collection of attributes. Key is attribute ID, value is the attribute value.

Device Read Helper API

For some commonly used attributes, helper functions are provided.

Libre_DeviceOnOffGet(id)

Get the current on/off state of the device. Note this API also works with “Level Control” device.

Parameters:

  • id - Integer, internal device ID.

Returns:

  • true if device is on; otherwise false.

Note: For “Level Control” device, true is returned if level is not 0; otherwise returns false.


Libre_DeviceLevelGet(id)

Get the current level of the device. Note this API also works with “On/Off” device.

Parameters:

  • id - Integer, internal device ID.

Returns:

  • true if device is on; otherwise false.

Note: For “On/Off” device, 255 is returned if device is on; otherwise 0 is returned.