[英]Alexa can't discover device if interface is changed from Alexa.PowerController to Alexa.DoorbellEventSource
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:我对 Alexa Smarthome Skills 很陌生,所以我按照以下示例中列出的步骤进行操作,并能够让 Alexa 发现“Sample Switch”设备:
https://github.com/alexa-samples/skill-sample-nodejs-smarthome-switch/blob/master/instructions/README.md https://github.com/alexa-samples/skill-sample-nodejs-smarthome-switch/blob/master/instructions/README.md
I then followed the steps listed in the following tutorial to create a Doorbell Smarthome device:然后,我按照以下教程中列出的步骤创建了一个 Doorbell Smarthome 设备:
https://www.webgate.biz/aktuelles/blog/doorbell-event-source-for-alexa https://www.webgate.biz/aktuelles/blog/doorbell-event-source-for-alexa
But Alexa couldn't discover the device.但 Alexa 无法发现该设备。
What I essentially did was, to modify the following code section of the lambda function:我实际上所做的是修改 lambda 函数的以下代码部分:
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:我使用以下测试来测试 lambda 函数:
{
"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.我发现问题是缺少
"proactivelyReported": true
DoorBellEventSource接口的真实功能。
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"
}
]
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.