question

newuser-7f2f4fd0-56ca-4ddf-b14d-781bbffddf14 avatar image

How do I make my smart home device open for discovery?

I'm very new to the Smart Home Skills API, so forgive me if I'm asking any silly questions.

I have a board with an ESP8266 chip and wanted to make a smart doorbell using it. I've been following the tutorial from https://github.com/alexa/alexa-smarthome/wiki/Build-a-Working-Smart-Home-Skill-in-15-Minutes and I'm on the testing portion. The tutorial outlines everything needed on the lambda/AWS side of things but I'm still confused on how the device you make communicates with AWS.

I can tell that the two things my device needs to handle are discovery and the DoorbellPress event . For the time being, I just have my board running the "HTTPSRequest" example sketch with some of the settings put in. For discovery, should my board just keep sending a post request with the payload described in Discover.Response, and then only send a DoorbellPress event to the API when the button is pressed? I noticed the 2 way communication api just came out in October of this past year, so finding any tutorials or information on this has been difficult.

TLDR: I have a board that can connect to wifi and all I want to be able to do is push a button on it, and have my Alexa respond with a doorbell chime.

how-tosmart homedevice discoverynew productsbutton
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Gaetano@Amazon avatar image
Gaetano@Amazon answered

Dear customer,

thanks for posting. The usage of Lambda is mandatory for a smart home skill, meaning that your device cloud needs to be reachable from the Internet.

In your case particular case (ESP8266) you could just build an HTTPS server that sets / gets the state of your device, given the JSON you receive from the Alexa service when an user interacts with your device using voice or via the App.

Same thing for discovery: When you skill is enabled, Alexa will send a Discover directive to your device cloud.

In case of a DoorBell, don't forget to describe the Alexa.DoorbellEventSource within your response. This will let Alexa understand that this particular device is capable of raising DoorbellPress event.

{
    "event": {
        "header": {
            "namespace":"Alexa.Discovery",
            "name":"Discover.Response",
            "payloadVersion":"3",
            "messageId":"ff746d98-ab02-4c9e-9d0d-b44711658414"
        },
        "payload":{
            "endpoints":[
                {
                    "manufacturerName": "Sample Manufacturer",
                    "modelName": "Sample Model",
                    "friendlyName": "My Doorbell",
                    "description": "A smart doorbell",
                    "displayCategories": [ "DOORBELL" ],
                    "cookie": {},
                    "capabilities":
                    [
                        {
                            "type": "AlexaInterface",
                            "interface": "Alexa.DoorbellEventSource",
                            "version": "3",
                            "proactivelyReported" : true
                        }
                    ]
                }
            ]
        }
    }
}

As you already mentioned, you just need to send a DoorbellPress event to the event gateway when the button is pressed. Here is an example:

{
    "context": { },
    "event": {
        "header": {
            "messageId": "9eac4fa2-9de0-4e75-ac38-9dde79abb1bd",
            "namespace" : "Alexa.DoorbellEventSource",
            "name": "DoorbellPress",
            "payloadVersion": "3"
        },
        "endpoint": {
            "scope": {
                "type": "BearerToken",
                "token": "access-token-from-Amazon"
            },
            "endpointId": "appliance-001"
        },
        "payload" : {
            "cause": {
                "type": "PHYSICAL_INTERACTION"
            },
            "timestamp": "2018-06-09T23:23:23.23Z"
        }
    }
}

More info here:
https://developer.amazon.com/docs/device-apis/alexa-doorbelleventsource.html

Kind regards,
Gaetano

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.