Writing Device Data

The following rules apply to write operations:

  1. Data must be always written into a property belonging to a device or app.

  2. All write operations return HTTP status code 200 with a receipt object stating how many data points are accepted and how many are rejected. In order to find out the cause of rejections, you should set the device to debug mode and check its logs.

  3. A valid data feed object must be provided as payload - see Data Feed.

  4. Valid credentials must be provided - see API Keys.

❗️

API Keys

In order to complete a write operation successfully the system requires to know the requester and the destination object identities. A destination object can be a device or app property.

API key credentials conveyed in the basic authentication header provides Connio with both the identity of the requester (authentication), and the authorization information. A combination of URL path and prop attribute defined in the data feed or object provides the system with the destination object identity.

In many cases the system acts differently on the request based on the requester's identity. For example, if the requester is a device, and the request is a write operation, the system doesn't consider this as a device command and send it to the physical device. On the other hand, if the requester is an external entity, then it considers it as a device command and sends this data to the device automatically over MQTT. We are going into details of this mechanism shortly.

Below we write data into a public device property called "SetPoint" using an api client key:

curl -X POST https://api.connio.com/v3/data/devices/thermostat/properties/setpoint \
    --user {apiclient_apikeyid}:{apiclient_apikeysecret} \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    -d @payload.json

❗️

Data Resolution

The time resolution of data points is millisecond. Data points that are written into a property with the same timestamps at this resolution will overwrite each other in the time-series database, but they are stored separately in the event journal.