Get Cloud property from device

Context

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.

@mbertorello

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.

@adriens
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 :slight_smile:

u.

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