API Overview
Usecases
Cheatsheet
Point metadata
Sometimes you want to set some device specific settings and state server side, and let the client retrieve it at will. You can do that in D4 by using the point metadata. Read on to see how.
Set medatata
You can set the metadata field when creating the point, or you can update it later.
mutation UPDATE_METADATA {
point {
update(input: {
id: ${pointID}
point: {
metadata: {any:"JSON" value:10}
}
}) {
id
metadata
}
}
}
Send metadata
In order for the device to retrieve the metadata you need to send it to the device. The optional retain flag can be set to true in order for this config to be retained. That means that the last sent object will received when subscribing.
mutation SEND_METADATA{
point {
command(input: {
pointId: $[pointId}
type:METADATA
retain: true
}) {
success
}
}
}
Subscribe
The way you retrieve the data via mqtt is subscribing to a special topic. In this example it is demonstrated using mosquitto_sub.
> mosquitto_sub -u ${mqtt-username} -P ${mqtt-password} -h mqtt.dimensionfour.io -t POINT/${mqtt-username}/${pointId}/METADATA
> {any:"JSON" value:10}