smart-product-solution
smart-product-solution copied to clipboard
Relationship between command and shadowDetails
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.
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.