2
votes

I have an IoT thing which publishes -

timestamp, isAdmin and data

on a topic

"iot/sampledata"

and I have a rule which listens to this topic and pushes this data to a DynamoDB. A user is able to update the isAdmin boolean to false using the device shadow feature from an app. How can i connect the device shadow to the rule engine so that i can update the isAdmin boolean in the DynamoDB as the shadow is updated.

I saw the shadow mqtt topics but i am missing some thing and it somehow does not work.

Any help is deeply appreciated.

1
Something would have to subscribe to the shadow mqtt topic to handle that update. You said you noticed the shadow mqtt topics, but what have you tried doing with them so far?Mark B
I saw the shadow mqtt topic "$aws/things/pSensor/shadow/update" and changed my rule query statement to SELECT desired FROM '$aws/things/pSensor/shadow/update'. Now i publish to this topic the valid JSON with the state and desired fields but no data ends up in dynamoDan

1 Answers

0
votes

Few hints i can give, which may help you.

  1. I am using query like, select clause you can cross check from structure in your shadow. SELECT state.reported.* FROM '$aws/things/pSensor/shadow/update/accepted'
  2. Test your topic "$aws/things/pSensor/shadow/update/accepted" using mqtt client given in AWS IoT itself. Subscribe to the topic and send data from your mobile app.
  3. In JSON (data publishing by mobile), if any of the key or value is blank, it will not work. In my case i was sending valye "NA" instead of "" (blank).
  4. Most important, In your existing AWS IoT Rule add Error Action as well and push error details in a SQS and subscribe to SQS in management console. It will give details in queue if there is any error. Data in SQS would be in Base64 encoding, so you can decode the same online.
  5. I am sure your DynamoDB action would have correct syntax. I am using say for primary key like "${state.reported.isAdmin}" (You can match it with your shadow).

Do let me know if it was helpful.

Regards,

Krishan