我正在使用AWS Lambda实施Alexa Home Skill。
鉴于我尝试在Alexa Skil测试页上检测到新设备时收到以下请求:
{directive={header={namespace=Alexa.Discovery, name=Discover, payloadVersion=3, messageId=0160c7e7-031f-47ee-a1d9-a23f38f87a9e}, payload={scope={type=BearerToken, token=...}}}}
我回应以下内容:
{
"event": {
"endpoint": {
"endpointId": "INVALID",
"scope": {
"type": "BearerToken",
"token": "INVALID"
}
},
"payload": {
"endpoints": [
{
"displayCategories": [
"SMARTPLUG"
],
"capabilities": [
{
"type": "AlexaInterface",
"interface": "Alexa",
"version": "3"
},
{
"type": "AlexaInterface",
"interface": "Alexa.PowerController",
"version": "3",
"properties": {
"retrievable": true,
"supported": [
{
"name": "powerState"
}
],
"proactivelyReported": true
}
},
{
"type": "AlexaInterface",
"interface": "Alexa.EndpointHealth",
"version": "3",
"properties": {
"retrievable": true,
"supported": [
{
"name": "connectivity"
}
],
"proactivelyReported": true
}
}
],
"manufacturerName": "mirko.io",
"endpointId": "ca84ef6d-53b1-430a-8a5e-a62f174eac5e",
"description": "Sample Endpoint Description",
"friendlyName": "forno"
}
]
},
"header": {
"payloadVersion": "3",
"namespace": "Alexa.Discovery",
"name": "Discover.Response",
"messageId": "dec8f5a8-4362-4646-aa72-c06c752f95ef"
}
}
}
尽管出于某些原因,Alexa回答它没有找到任何新设备。我可能会弄错了,但是在我决定添加Alexa.EndpointHealth接口之前,我很确定它曾经可以正常工作。
您的响应对象对我来说似乎正确,除了额外的"endpoint"
字段。
"endpoint": {
"endpointId": "INVALID",
"scope": {
"type": "BearerToken",
"token": "INVALID"
}
}
Alexa.Discovery文档中没有此类字段。尝试将其删除,看看是否可以解决问题。