- Newest
- Most votes
- Most comments
Hi,
one option is to report back additional state in the shadow so that the application that set the desired state is able to take the appropriate action to solve the issue.
For example, you device could report:
{
"reported": {
"error": "Invalid mode invalid_mode not applied",
"mode": "off"
}
}
You can then have a rule subscribing to shadow updates messages and check for any errors.
To avoid the infinite loop with deltas, you should use the timestamp
metadata associated with the delta:
{
"version": 19,
"timestamp": 1665991032,
"state": {
"mode": "invalid_mode"
},
"metadata": {
"mode": {
"timestamp": 1665991016
}
}
}
By storing the timestamp
value of the latest delta you answered to, you can check if the the new delta changes are related to something you have already processed or not. Above is the delta you get after sending the update leaving mode
unchanged. The timestamp associated to the mode
indicates the time when the desired mode
was changed and this enables your client to track which updates you have already processed and which not.
I would also advise to validate the desired values you set in the shadow cloud side.
For a more powerful and flexible mechanism to send updates to devices you can also look into AWS IoT Jobs which allow you to report additional status information and errors.
Relevant content
- asked 2 years ago
- asked a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
Hi, thank you for the reply Massimiliano.
Correct me if I am wrong, but if I store the timestamp of the invalid mode update locally and use it to check against incoming deltas for this same property, wouldn't this only stop my local device from processing the deltas, not receiving them. For example, the device shadow will maintain this state:
So it will continue to publish Deltas to my device, which I could ignore, but I would rather avoid this situation.