Intermediate Tutorial


IoT Thing, Shadow, and Script Actions


1 hour

Posted on: November 20, 2017

Learn Sumerian
IoT Thing, Shadow, and Script Actions

Tags

entities
transform
state machine
scripting
iot
inspector panel

In this tutorial you will learn about:

integrating Sumerian with AWS IoT

Thing Shadows can be used in a variety of ways, including for command and control. In this tutorial, we focus on modeling the reported state of a Thing (its Shadow state) in Amazon Sumerian. What the Thing is isn’t as important. For our example, while some might assume physical hardware is necessary, we can just use the IoT console to simulate the data our Thing publishes. Our Thing is a Box that rotates on a vertical axis about its center (we’ll call this the Y axis). We’ll use an integer value between 0 and 359 when reporting the state of rotation of the box.

Prerequisites

Before you begin, you should have completed the following tasks and tutorials:

Step 1: AWS Prerequisites

  1. Create an Amazon Cognito identity pool with an Unauthenticated Role, which has the AWSIoTFullAccess and AWSIoTDataAccess IAM policy attached. To learn more, see the AWS Configuration tutorial.

  2. Use the IoT console to create our entity’s Thing Shadow by publishing a message on the box’s Shadow Topic $aws/things/box/shadow/update, with a payload that represents the Thing’s default rotation. Note: Make sure you are using the same region for both AWS IoT and Sumerian!

{
    "state" : {
        "reported" : {
            "y_rotation" : 0
         }
     }
}

Step 2: Create a New Scene

From the Dashboard, create a new scene using the Default Lighting template.

Step 3: Configure the New Scene for AWS

In order for the scene to retrieve the Thing Shadow, it needs to be configured with an Amazon Cognito identity pool. Under the AWS configuration component, make sure to enable the IoT Data Client by checking the checkbox.

  1. In the Entities panel, select the root, or scene, entity (in our case, IoT + Script Action Tutorial) to see the AWS Configuration component.

  2. Provide your Amazon Cognito pool ID, and then Enable the IoT Data client.

  3. Make sure to use the most current AWS SDK url, which can be found on the AWS SDK for JavaScript Getting Started guide, under Step 4.

  4. Insert the current url in the AWS SDK URL property.

Step 4: Create an Entity

  1. Choose Create Entity at the top of the canvas.
  2. From the Create entity menu, under the 3D Primitives category, choose Box.

  3. In the Inspector panel on the right, choose the Box tab. This displays the general information about the selected entity.