Dan
Dan

Reputation: 829

AWS IoT device shadows concept

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.

Upvotes: 2

Views: 621

Answers (1)

Krishan Babbar
Krishan Babbar

Reputation: 798

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

Upvotes: 0

Related Questions