Updated on 2022-08-11 GMT+08:00

Device Twin Update

This topic is used to subscribe to device twin updates. It reflects the differences before and after a device twin update.

Topic

$hw/events/device/{device_id}/twin/update/document

Parameter

Type

Description

device_id

String

End device ID.

Usage

Use an MQTT client to subscribe to this topic.

Parameter Description

Parameter

Type

Description

event_id

String

Event ID.

timestamp

Int64

Timestamp when the event occurred.

twin

Object

A set of updated device twins. Each twin is in the key-value pair format. The value contains last (twin information before the update) and last (twin information after the update). The twin information contains the option flag, the twin metadata contains the value type, the expected status contains the expected value and update time, and the actual status contains the actual value and update time.

Example

When an end device is bound to an edge node, the following message is received:

$hw/events/device/{device_id}/twin/update/document
{
     "event_id":"",
     "timestamp":1557314742122,
     "twin":{
         "state":{
             "last":null,
             "current":{
                 "expected":{
                     "value":"running",
                     "metadata":{
                         "timestamp":1557314742122
                     }
                 },
                 "optional":true,
                 "metadata":{
                     "type":"string"
                 }
             }
         }
     }
 }