简体   繁体   English

如果接口从 Alexa.PowerController 更改为 Alexa.DoorbellEventSource,Alexa 无法发现设备

[英]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.

相关问题 Alexa 的 Google 助理技能 - Google Assistant Skill for Alexa 亚马逊 Alexa 阅读谷歌电子表格 - Amazon Alexa reading Google Spreadsheets 将数据上传到 Firesbase 后 Alexa 技能没有响应 - Alexa skill not responding after uploading data to firesbase alexa技能免费怎么赚钱,而亚马逊服务是收费的? - How do alexa skills earn money if they are free, but amazon services have a cost? 无法从 firebase 登录谷歌帐户 - Can't login into google account from firebase 无法让 Firestore 从 Android Studio 中的集合返回字段值 - Can't get Firestore to return a field value from a collection in Android Studio React-Native 无法从 Firestore 响应中访问二级 - React-Native can't access second level from firestore response 我无法在我的模态 React 中从 map function 发送数据 - I can't send data from map function inside my modal React 无法解析符号“FirebaseRecyclerOptions&lt;&gt;” - Can't resolve Symbol 'FirebaseRecyclerOptions<>' 无法将部署从 apiVersion extensions/v1beta1 升级到 apps/v1,它会自动使用 extensions/v1beta1 - Can't upgrade Deployment from apiVersion extensions/v1beta1 to apps/v1, it uses extensions/v1beta1 automatically
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM