Skip to content

State messages

A device sends a state message each time it reports a change. The Kafka key is the device id, so the topic keeps the latest message of every device.

{
"eventTime": 1764727200123,
"states": {
"6732e0f07b3699465a943dc6": {
"1": { "1": [1, 1], "28": [28, 750] }
}
},
"changes": {
"6732e0f07b3699465a943dc6": {
"1": { "28": [28, 750] }
}
},
"userId": "yKYptZq3bOP0bgfr2FmV39m6rYt2"
}
Field Type Meaning
eventTime number (ms) When Thing Edges received the report. It is not the device’s clock
states object The device’s full state after this report, by device id
changes object Only what this report changed. Same shape as states
userId string The app user the device belongs to

Each message carries one device: states and changes have one key, the same as the message key.

{ "<element>": { "<attribute>": [attribute, value, value, …] } }
  • Element: the part of the device, such as one gang of a switch. Numbers are strings.
  • Attribute: what is reported, such as on/off (1) or brightness (28). The array repeats the attribute id, then its values.

In the example, element 1 is on ("1": [1, 1]) and its brightness changed to 750 out of 1000 ("28": [28, 750]). What every attribute’s values mean is in Reading attributes and the attribute tables.

  • Key by device id and keep the message with the newest eventTime. A repeat or an older message then changes nothing.
  • Use changes to react to what happened, and states to store the current state.
  • An element or attribute you do not know is not an error: devices may report attributes added later.