Should the `thing-example.js` thing be setting the "reported" state instead of "desired"?
See original GitHub issueI’m still wrapping my head around the intended use of reported vs desired, but based on my current understanding the desired state is basically “Thing, I would like you to change your state to this new state” - i.e. in the example of a remote IoT lightbulb and a phone app, the phone app would set the desired state of the thing to tell the light that it should go to that state.
The reported state is what the light would return back with, to let AWS IoT know that it was it’s state. This could be done as a confirmation that the state had been moved to match the desired state, or it could be used to indicate that some external force caused the thing to go to that state (maybe somebody hit a remote control that changed the light to a new state).
Again, I could be totally off on my understanding and would greatly appreciate being corrected if so!, but if not, then the example thing-example.js seems to be a bit confusing because the thing part of the example sets the desired state. Again I’m probably thinking about htis all wrong, but it just seems to me like the “thing” should be setting the reported value?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
Hi @develpr ,
Thank you very much for your interest in AWS IoT.
Thanks to @groteworld 's explanation. You can actually think about the following model:
Basically, your device and you application are connected to each other through AWS IoT Device Shadow and its delta mechanism. You can control your device from your application by simply updating your shadow state.
For more details, you can take a look at the following documentations: http://docs.aws.amazon.com/iot/latest/developerguide/thing-shadow-mqtt.html#update-delta-pub-sub-topic http://docs.aws.amazon.com/iot/latest/developerguide/thing-shadow-data-flow.html
You can also take a look at a more use case related sample provided along with the Node.js SDK: https://github.com/aws/aws-iot-device-sdk-js/tree/master/examples/temperature-control
Thanks, Liusu
I think you are just missing a small part of a thing shadow’s document which is the
delta. If thereporteddoesn’t match thedesiredadeltais create that states the desired. A thing can then handle changing to that missingdesiredstate.Example:
Here the shadow is stating there is a desired change,
delta, and it will remain there until thereportedstate returns the same as thedesired.In the case of the example
thing-example.jsit is settingdesiredbecause it handles its “light” changing through the delta. since thereported(null) will never bedesired(random RGB), thedeltais always being updated and it’s event can be listened for.I hope this helps!!