aws-solutions / smart-product-solution

The Smart Product Solution is a customer deployable reference architecture to help manufacturers to jumpstart development of innovative connected/smart product services.
Apache License 2.0
28 stars 20 forks source link

Relationship between command and shadowDetails #7

Open billkidwell opened 4 years ago

billkidwell commented 4 years ago

In source/services/api/command/lib/command.js the shadowDetails include attributes that we do not necessarily want to change.

For the command set-temp, all three attributes will be sent, even though only the targetTemperature should be updated.

For the command set-mode, all three attributes will be sent, even though only the powerStatus should be updated.

In the case of actualTemperature, nothing should be updating that value from the console.

Is there a best practice around sending the entire state? It seems to me that the shadowDetails should be limited to the values that are meant to change, especially if they are being published in the shadow's desired attribute. If there is a good reason to send the state that the client has, then it would make more sense to me to put that state in the reported section.

As I expand this solution to numerous commands, I want to implement the correct pattern. I could offer a pull request to address these issues if it would be helpful.

gsingh04 commented 4 years ago

Hello,

You are correct here. The recommended approach is indeed limiting shadow update to the values that are meant to change, in the desired attribute. Please feel free to submit the pull request from your working implementation. PR

Reference link for working with shadow details, [here].(https://docs.aws.amazon.com/iot/latest/developerguide/using-device-shadows.html#delta-state)

We appreciate your collaboration on the solution.