简体   繁体   中英

How to syncronize Azure IoT Hub device twin with device changes?

For our IoT solution we are trying to tackle a synchronizing issue with the device Twin.

In the normal situation the Cloud is in charge. So the cloud will set a desired property in the IoT hub device twin. The device will get a notification, change the property on the device and write the reported property that the device is in sync.

But for our case the user of the device can also change properties locally. So in this case the reported property will change and is out of sync with the desired. How should we handle this? update the desired? leave it as is?

And a other case can be that properties can be deleted from both sides. see the attacted picture.

Writen use cases

here an example of the json twin:

"desired" : {
 "recipes" : {
  "recipe1" : {
   "uri" : "blob.name.csv",
   "version" : "1"
   },{
  "recipe2" : {
   "uri" : "blob.name.csv",
   "version" : "1"
   },{
  "recipe3" : {
   "uri" : "blob.name.csv",
   "version" : "1"
   }
 }
},
"reported" : {
 "recipes" : {
  "recipe1" : {
   "uri" : "blob.name.csv",
   "version" : "1"
   },{
  "recipe2" : {
   "uri" : "blob.name.csv",
   "version" : "3"
   },{
  "recipe3" : {
   "uri" : "blob.name.csv",
   "version" : "2"
  }
}

I hope the question is clear. Thanks in advance.

Kind regards,

Marc

The approach to conflict resolution is specific to the business, it's not possible to define a universal rule. In some scenarios the user intent is more important than the service, and viceversa.

For instance an employee working late wants an office temperature of 76F, and automatic building management service wants a temp of 70F out of hours, in this case the user wins (desired property is discarded). In another example, an employee wants to enter the office building out of hours and turn on all the light, but the building management service won't allow it (while a building admin would be allowed instead...) etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM