Device Mirroring over MQTT
Device mirroring gives you real-time read-only access to all device properties that have their publish
attribute set to always
or changed
.
In order for the device mirroring to work, the device must be plugged into at least one app. This app serves as the context to read device data. It is not possible to access device data directly. In case the device is plugged into multiple apps, device data can be accessed from all these apps.
REMEMBER
In order for the device mirroring to work, the device must be plugged into at least one app.
In its longest form, device mirror topic looks like the following:
<account-name>/apps/<app-name>/devices/<device-name>/properties/<property-name>
Alternatively, clients can subscribe to a single device mirror topic in order to listen to data generated from all devices that are plugged into the app in question:
<account-name>/apps/<app-name>/devices/#
An API client key with Application
context and device:read-data
scope is required to connect to the Connio broker in order to subscribe to a device mirror topic as shown below:
POST https://api.connio.com/v3/apiclients
{
"name": "Data-Subscriber",
"description": "An api client to listen incoming data of devices plugged into the default app via Connio MQTT broker.",
"context": {
"type": "app",
"ids": ["_app_918165076511726851"]
},
"scope": ["device:read-data"]
}
In such scenario, the user should connect the broker using this API Client credentials (i.e. API Client id as MQTT Client id, key id as username and secret as password), and subscribe to the device mirror topic as shown below.
inbiza/apps/smart-irrigation/devices/ir.1/properties/soiltemp
IMPORTANT
Device mirror topic path names must be lower-case.
See API Cheatsheet section of the device to get the actual device mirroring address.
Updated almost 7 years ago