How to change "desire" of shadow from the IOT device?

#1

I want to control LED from both the REST API and a button in IOT .
When ever i change the State of the LED, the Cloud send back an “UPDATE DELTA” and then change the LED status back(Which i dont want).

So is there any way to change the “desired” of the shadow from the iot device?

#2

What framework are you using - Mongoose OS, Arduino IDE or ESP-IDF?

#3

Mongoose OS. and i am using NodeMCU ESP8266.

#5

I make a POST request to the Mongoose cloud like this.

HTTP.query({
  url: 'https://mdash.net/api/v2/devices/device2?access_token=xxxxxxxxxxx',
  headers: { 'Content-Type': 'application/json' },
  data: mdata,      // { shadow: { state: { desired: { built_in: boolean}}}}
  cert: 'cert.pem',  // client certificate // just left it if you dont have this file
  key: 'key.pem',  // client key  //just left if you dont has this file
  ca_cert: 'ca.pem',  // ca bundle to verify server with ""
  success: function (body, full_http_msg) { print("body"); },
  error: function (err) { print(err); }
});

“ca.pem” is from https://github.com/mongoose-os-libs/ca-bundle/blob/master/fs/ca.pem

#6

You can use a lower-level dash API:

    mgos_dash_notifyf("Dash.Shadow.Update",
                      "{version: %d, state: {desired: {foo: %d}}}", 0, 123));
1 Like