Green1234
Green1234

Reputation: 33

Azure IoT Hub Desired and Reported Propery

In the Azure Hub device twin we have Desired Properties and Reported Properties. I guess that is like a setpoint and actual value.

So when I want to change a value I update the Desired Property and then wait for the corresponding Reported property to be updated with the actual value would that be right?

When updating the Desired Property, is it normal practise to not touch the corresponding Reported Property? I mean set it to null or something to indicate that we do not have an actual reported value yet... If the device property was indeed updated but the the report message from the device fails to arrive we will have an old reported value. I would think it should not be updated and maybe there are timestamps for these properties to see if the reported value is not yet updated.

Upvotes: 0

Views: 1167

Answers (1)

Matthijs van der Veer
Matthijs van der Veer

Reputation: 4085

It's not normal practice to change the reported properties of a device when changing the desired property. If the device has not reported that property, it simply won't be available in the reported properties. So to answer both of your questions, here's a scenario:

  1. Your device is running, having a great time. It has received no desired properties and has reported no properties of its own.
  2. You go to the portal and add a desired property, the property foo with a value of bar, you change nothing else.
  3. The device receives the request for this property, implements the change and reports to the IoT Hub that foo is now bar.
  4. Looking at the device twin in the portal, you notice a reported property, also the metadata for the reported properties indicates a $lastUpdated value with a timestamp.

Reported properties are just that, reported. A device can report properties that aren't in the desired properties, or update a reported property without receiving a new desired property.

Upvotes: 1

Related Questions