Go Down

Topic: Get Cloud property from device (Read 744 times) previous topic - next topic



On a property, I need my device to be able to get the value  from the cloud, ie. not reset it locally. For now everything is reset while I reboot my device, I'd like to restore the value with the cloud's value : any idea on how to perform this please ?


This feature is implemented is called Shadow Thing

Please share more information and your sketch so we can help you.



The problem is when you need to set the first value from the board at initial run, I have helped someone else on the same issue.

You can add a boolean flag as one of your properties and not initialise the variables in setup but only on connect.
if you care to share your sketch I'll rework it to help you out.

essentially it's like this
- subscribe to the callback for onSync
- in the callback check for the state of your flag (could be a property named "initialSetupDone")
- if this property is false set the initial values which will be sent to cloud
- if it's false do not set them and you'll automatically obtain the Shadow Values from the Cloud

let me know if you need more detailed work :)



goes without saying that if you want to run a new "initial setup" you'll have to set that flag to false somehow :)

Go Up