Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Programming the Physical World with Device Shadows and Rules Engine

2,639 views

Published on

Learn more about how to use AWS IoT's Device Shadows and Rules Engine to build powerful IoT applications.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Programming the Physical World with Device Shadows and Rules Engine

  1. 1. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. John Rotach Software Development Engineer – AWS IoT September 27, 2016 Programming the Physical World with AWS IoT Device Shadows and Rules Engine
  2. 2. Outline • Shadows • Rules • Putting it all together
  3. 3. The Story A connected wind farm
  4. 4. AWS IoT
  5. 5. Shadows
  6. 6. AWS IoT
  7. 7. AWS IoT – Thing’s shadow Device Shadow Applications
  8. 8. AWS IoT Device Shadow - Simple Yet Powerful { "state" : { “desired" : { "lights": { "color": "RED" }, "engine" : "ON" }, "reported" : { "lights" : { "color": "GREEN" }, "engine" : "ON" }, "delta" : { "lights" : { "color": "RED" } } }, "version" : 10 } Device Report its current state to one or multiple shadows Retrieve its desired state from shadow Mobile App Set the desired state of a device Get the last reported state of the device Delete the shadow Shadow Shadow reports delta, desired and reported states along with metadata and version
  9. 9. 1. Device Publishes Current State 2. Persist JSON Data Store 3. App requests device’s current state 4. App requests change the state 5. Device Shadow sync’s updated state 6. Device Publishes Current State 7. Device Shadow confirms state change AWS IoT Device Shadow Flow
  10. 10. Simple Demo { "desired": { "pump_mode": "OFF” }, "reported": { "pump_mode": "OFF” } } Pump Controller
  11. 11. Device Shadow Applications
  12. 12. Rules engine
  13. 13. Rules engine
  14. 14. Rules engine: Extracting value from messages • Filter messages with certain criteria • Transform the payload of messages • React based on messages • Move messages to other topics • Move messages to other systems • Predict changes based on trends
  15. 15. Rules engine: Move messages to other systems Invoke a Lambda function Put object in an S3 bucket Insert, update a DynamoDB table Publish to an SNS topic or endpoint Publish to an Amazon Kinesis stream (and to EMR and Spark) Publish to Firehose Republish to AWS IoT Publish to Amazon ES Capture a CloudWatch metric or change an alarm Write to SQS queue
  16. 16. Rules engine: Move messages to other systems Publish to Amazon Elasticsearch Service Write to SQS queue Publish to an SNS topic or endpoint
  17. 17. A rule in AWS IoT aws iot create-topic-rule --rule-name WindFarmData --topic-rule-payload { "sql": "SELECT datapoint_id, current, rotation_speed, location, topic(2) as turbine_id, timestamp() as time, FROM 'wind-farm/+/data'", "description": "Save data from wind turbines into Elasticsearch", "actions": [ { "elasticsearch": { "roleArn": "arn:aws:iam::123456789012:role/aws_iot_windfarm", "endpoint": "https://my-es-endpoint.us-west-2.es.amazonaws.com", "index": "turbine-data", "type": "measurement", "id": "${CONCAT(datapoint_id, '_', turbine_id)}" }}]} RouteFilter, transform
  18. 18. new: Elasticsearch Integration
  19. 19. new: Predict Function
  20. 20. Putting it all together
  21. 21. Demo Analyze wind farm performance
  22. 22. amzn.to/iotwindfarm
  23. 23. Architecture
  24. 24. Takeaways: Shadows • Devices report state • Applications set desired state • Call APIs for devices, even when they’re offline • Sync state with PubSub • Consume deltas or complete state • Use version numbers
  25. 25. Takeaways: Rules • Use rules to store huge data volumes • Rule actions integrate with big data storage services • Use rules as triggers to drive your application • Transform data moving from or to devices • Supplement data with other data, predictions
  26. 26. Thank You!

×