I'm quite new to Alexa Smarthome Skills so I followed the steps listed in the following example and was able to get Alexa to discover the "Sample Switch" device:
I then followed the steps listed in the following tutorial to create a Doorbell Smarthome device:
https://www.webgate.biz/aktuelles/blog/doorbell-event-source-for-alexa
But Alexa couldn't discover the device.
What I essentially did was, to modify the following code section of the lambda function:
if (namespace.toLowerCase() === 'alexa.discovery') {
let adr = new AlexaResponse({"namespace": "Alexa.Discovery", "name": "Discover.Response"});
let capability_alexa = adr.createPayloadEndpointCapability();
let capability_alexa_powercontroller = adr.createPayloadEndpointCapability({"interface": "Alexa.PowerController", "supported": [{"name": "powerState"}]});
adr.addPayloadEndpoint({"friendlyName": "Sample Switch", "endpointId": "sample-switch-01", "capabilities": [capability_alexa, capability_alexa_powercontroller]});
return sendResponse(adr.get());
}
...to this:
if (namespace.toLowerCase() === 'alexa.discovery') {
let adr = new AlexaResponse({"namespace": "Alexa.Discovery", "name": "Discover.Response"});
let capability_alexa = adr.createPayloadEndpointCapability();
let capability_alexa_doorbell = adr.createPayloadEndpointCapability({"interface": "Alexa.DoorbellEventSource"});
adr.addPayloadEndpoint({"friendlyName": "Front door", "endpointId": "doorbell-01", "displayCategories": [ "DOORBELL" ], "capabilities": [capability_alexa, capability_alexa_doorbell]});
return sendResponse(adr.get());
}
I use the following Test to test the lambda function:
{
"directive": {
"header": {
"namespace": "Alexa.Discovery",
"name": "Discover",
"payloadVersion": "3",
"messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
},
"payload": {
"scope": {
"type": "BearerToken",
"token": "access-token-from-skill"
}
}
}
}
...and get the following response (for the doorbell), which seems fine:
Response
{
"event": {
"header": {
"namespace": "Alexa.Discovery",
"name": "Discover.Response",
"messageId": "29ffa439-cc19-47f6-8996-7da21bb79420",
"payloadVersion": "3"
},
"payload": {
"endpoints": [
{
"capabilities": [
{
"type": "AlexaInterface",
"interface": "Alexa",
"version": "3"
},
{
"type": "AlexaInterface",
"interface": "Alexa.DoorbellEventSource",
"version": "3"
}
],
"description": "Sample Endpoint Description",
"displayCategories": [
"DOORBELL"
],
"endpointId": "doorbell-01",
"friendlyName": "Front door",
"manufacturerName": "Sample Manufacturer"
}
]
}
}
}
I figured out that the problem was a missing "proactivelyReported": true
capability for the DoorBellEventSource interface.
The correct response should've looked like this:
{
"event": {
"header": {
"namespace": "Alexa.Discovery",
"name": "Discover.Response",
"messageId": "9b3c332e-73ca-42e8-9dbf-7f313ac5fb02",
"payloadVersion": "3"
},
"payload": {
"endpoints": [
{
"capabilities": [
{
"type": "AlexaInterface",
"interface": "Alexa",
"version": "3",
"proactivelyReported": false
},
{
"type": "AlexaInterface",
"interface": "Alexa.DoorbellEventSource",
"version": "3",
"proactivelyReported": true
}
],
"description": "Sample Endpoint Description",
"displayCategories": [
"DOORBELL"
],
"endpointId": "sample-doorbell-01",
"friendlyName": "Sample DoorbellEventSource",
"manufacturerName": "Sample Manufacturer"
}
]
}
}
}