How does smart devices know which task to perform?

85 Views Asked by At

I have been trying to build an Alexa skill for the smart device but thing I don't understand if I send a request to the smart device using my Alexa then how does it know which task to perform. I understand till Alexa made a call to the lambda function then it make an api call to the smart device server but what I don't understand how does the device know that it has to it has to turn itself off or change the color of the light etc. Do we have to write special programming for that? Please, someone, explain how does it works as I am new here I am unable to understand it. Thank you in advance.

2

There are 2 best solutions below

0
On

You are right on the call being made to the smart device server. the activity details lies in the API that is requested.

Check the device URL (generally contains action name eg: Power) and body (contains action detail as Json like {"state":"on"})

So to write a smart device application you will need the API list for controlling the device

0
On

So Basically, Your echo device will give you the Event and Handler information when you speak to the Echo device.

Alexa.PowerController and Alexa.ColorController

These are the namespace by which you will have an idea to your programming which command you would like to use. for ex.

{
    "directive": {
        "header": {
            "namespace": "Alexa.PowerController",
            "name": "TurnOn",
            "payloadVersion": "3",
            "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
            "correlationToken": "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg=="
        },
        "endpoint": {
            "scope": {
                "type": "BearerToken",
                "token": "access-token-from-skill"
             },
            "endpointId": "appliance-001",
            "cookie": {}
        },
        "payload": {}
    }
}

For more details in depth please visit powerControl and colorControl documentation. This is one more example.

Hope, this may help you.