Hi there,
I’m trying to create a device that can be controlled via the internet. I’d like to use the AWS IOT cloud for that. But this device can also be controlled from local inputs. So for the sake of example let’s say there is a lamp and a button connected to this device. When I push the button I need to turn off/on the light. But I also would like to send a command to turn it off/on from the internet. Device shadow could do this, but I wouldn’t like to keep track of the actual device state. So if there is a connection error and the user sends a “turn off” command from a remote location, but later on (while the connection is still interrupted) someone turns on the light locally, I wouldn’t like to turn it off again, once I receive the shadow delta when the device is reconnected.
The AWS documentation (Mongoose OS Documentation) states that I should be able to send message to the desired channel, to update the desired values instead of the reported. So I thought then upon booting and reconnecting I just send an empty object to the “desired” channel, but this didn’t work. Instead it added it to the reported state.
This is the code that I used:
AWS.Shadow.update(0, {desired: {}});
And the resulting device shadow was this:
{
"state": {
"desired": {
"welcome": "aws-iot",
"test": "1"
},
"reported": {
"welcome": "aws-iot",
"desired": {}
},
"delta": {
"test": "1"
}
}
}
Am I missing something here?
I was also thinking about not using AWS IOT at all, and only subscribing to an MQTT server and sending non-retained messages, but that way I’ll have to deal with device authentication which would be nice to avoid.
Thanks,
Zoltan