How to make aws-iot to reject shadow change requested by a device

0

Hi, My case: Let say device1 is publishing a state to topic $aws/things/device1/shadow/update with payload

{
  "state": {
    "reported": {
      "msg1": "hello1"
             }
   }
    "desired": {
      "msg2": "hello2"
             }
   }
}

Actual Scenario: Lets say shadow document was empty and as soon as this message is received to broker aws-iot will push this state to shadow document (i'm using unnamed classic shadow) . So my shadow document will look like somewhat same as payload

{
  "state": {
    "reported": {
      "msg1": "hello1"
             }
   }
    "desired": {
      "msg2": "hello2"
             }
   }
}

My Scenario: I want to make aws-iot to not to push reported field to shadow document. So my shadow document should look like

{
  "state": {
    "desired": {
      "msg2": "hello2"
             }
   }
}

Query: So is this possible? if yes, how can i configure it? Thanks

asked 8 months ago187 views
1 Answer
1

Hello, there is currently no way to help you implement this feature.

Shadow topics show that you can only modify shadow by publish message to $aws/things/thingName/shadow. update-pub-sub-topic show that message body contains a partial request state document.

A request state document has the following format:

{
    "state": {
        "desired": {
            "attribute1": integer2,
            "attribute2": "string2",
            ...
            "attributeN": boolean2
        },
        "reported": {
            "attribute1": integer1,
            "attribute2": "string1",
            ...
            "attributeN": boolean1
        }
    },
    "clientToken": "token",
    "version": version
}

if you want only modify desired status but stay reported status,you should let device publish:

{
  "state": {
    "desired": {
      "msg2": "hello2"
     }
   }
}

If the state of the device changed, you should let device publish:

{
  "state": {
    "reported": {
      "msg1": "hello1"
     }
   }
}
profile pictureAWS
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions