Reading Data from Device Cloud in Python
A client application can read the current value of an attribute or property from Device Cloud.
The value may have been published from either an application or a trigger action. For more information about trigger publish actions, see the following:
- Device Cloud Management Portal User's Guide: attribute.publish Action
- Device Cloud Management Portal User's Guide: property.publish Action
The functions to read attributes and property values from Device Cloud specify the name of the attribute or property and return the value and the timestamp of the value.
To read the value of an attribute or property, you need the key of the attribute or property defined in the thing definition and at least one value available in Device Cloud.
To read data in Device Cloud, the application must be connected to Device Cloud.
In the following example, rvalue is the value of the property from Device Cloud and timestamp is the time in datetime format that the value was published to Device Cloud.
status, rvalue, timestamp = client.telemetry_read_last_sample(myPropertyKey)
Examples
The iot-simple-telemetry.py sample application provided with the agent shows example code for reading data from Device Cloud.