Skip to content

Latest commit

 

History

History
55 lines (42 loc) · 2.64 KB

File metadata and controls

55 lines (42 loc) · 2.64 KB

Step 9: Send an Event

Send an external event into Alexa from the Endpoint Device backend. This simulates an external event on the endpoint that will need to be updated with Alexa.

9.1 Send a Proactive State Update

9.1.1 In Postman, and within the Endpoints sub-folder, open the POST /events resource from the left menu.

9.1.2 Select the Body tab and view the raw JSON. It should look like the following:

{
    "event": {
        "type": "ChangeReport",
        "endpoint": {
            "userId": "{{user_id}}",
            "id": "{{endpoint_id}}",
            "state": "OFF",
            "type": "SWITCH",
            "sku": "SW00"
        }
    }
}

Note that the user_id and endpoint_id are variables that can be updated via the Postman environment variables.

9.1.3 Update the Postman environment variables by replacing the user_id "0" value with the [user_id] stored in the config.txt file. Additionally, replace the endpoint_id value with the Thing name from AWS IoT for the Sample Black Switch created. When edited, it should something like the following:

{
  "event": {
    "endpoint": {
    	"userId" : "amzn1.account.XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    	"id": "b0dcb3f0-db26-4462-8cf1-15fc97972eac",
    	"state": "OFF",
    	"type": "SWITCH",
        "sku": "SW00"
    }
  }
}

9.1.1 Click Save in the top right and then and then click the Send button.

9.1.2 Return to the AWS IoT Things console and note the state value of the created Black Sample Switch. The state should reflect the "state" value passed in the body. For instance, if set to "OFF", the attribute state will be set to OFF.

Finally, while that method updates the Endpoint Cloud data, you can see the state of the response sent to the Alexa event gateway in Postman on the right of the Response section. A 202 value of Accepted indicates the message was received. For a full list of Success responses and errors, visit the documentation at https://developer.amazon.com/docs/smarthome/send-events-to-the-alexa-event-gateway.html#success-response-and-errors. If ultimately successful, the state of the Black Sample Switch will change in the Alexa web and mobile applications.



Go to Step 10: Clean Up.


Return to the Instructions