简体   繁体   English

Alexa 智能家居技能:发现设备的问题

[英]Alexa smart home skill: problem with discover devices

I have problems with the discovery of devices of my Alexa Smart Home skill.我在发现 Alexa Smart Home 技能的设备时遇到问题。

Steps which work:工作步骤:

My problem: After the Alexa Skill returns from discovery of devices task, no new devices are visible in the Alexa Skill.我的问题:在 Alexa Skill 从发现设备任务返回后,Alexa Skill 中看不到新设备。

When I use the code from the sample (where no request to an external Rest API happens), the device is visible in the Alexa skill after the Alexa discovery task.当我使用示例中的代码时(没有对外部 Rest API 的请求),在 Alexa 发现任务之后,该设备在 Alexa 技能中可见。

 var https = require('https'); const AWS = require('aws-sdk'); exports.handler = function(request, context) { var options = { method: 'GET', hostname: 'xyz.azurewebsites.net', path: '/devices', headers: { Authorization: 'Bearer ' + request.directive.payload.scope.token, 'Content-Type': 'application/json' } }; var req = https.get(options, (response) => { var data = ''; response.setEncoding('utf8'); response.on('data', function(x) { data += x; } ); response.on('error', console.error); response.on('end', () => { var dataObj = JSON.parse(data); console.log("Retrieved response: " + JSON.stringify(dataObj.items)); const payload = { "endpoints": [] }; dataObj.items.forEach(item => { const device = { "endpointId": item.id, "manufacturerName": item.manufacturer, "friendlyName": item.displayName, "description": item.description, "displayCategories": ["SWITCH"], "cookie": { "key1": "arbitrary key/value pairs for skill to reference this endpoint.", "key2": "There can be multiple entries", "key3": "but they should only be used for reference purposes.", "key4": "This is not a suitable place to maintain current endpoint state." }, "capabilities": [ { "type": "AlexaInterface", "interface": "Alexa", "version": "3" }, { "interface": "Alexa.PowerController", "version": "3", "type": "AlexaInterface", "properties": { "supported": [{ "name": "powerState" }], "retrievable": true } } ] }; payload.endpoints.push(device); }); console.log('payload ' + JSON.stringify(payload)); var header = request.directive.header; header.name = "Discover.Response"; console.log("DEBUG", "Discovery Response: ", JSON.stringify({ header: header, payload: payload })); //NEXT LINE IS EXECUTED WITHOUT ANY ERROR context.succeed({ event: { header: header, payload: payload } }); }); }); req.on('error', (e) => { console.log('problem with request: ' + e.message); }); };

I found the problem... The value of the property 'endpointId' contained a '@'.我发现了问题...属性“endpointId”的值包含一个“@”。 Then I changed the name to only letters, and it worked.然后我将名称更改为仅字母,并且它起作用了。 Although in this article it says '@' can be used, the discovery of devices then has problems.虽然在这篇文章中它说可以使用“@”,但设备的发现却有问题。 Hope this answer helps others from wasting time...希望这个答案可以帮助其他人不要浪费时间......

I found another cause for the same symptom: for the entity's additionalAttributes (manufacturer, model etc.), one cannot use non-English characters.我发现了相同症状的另一个原因:对于实体的附加属性(制造商、型号等),不能使用非英文字符。 You can actually use any character ASCII from 32 to 126 (space to tilde), but you cannot use the backslash.您实际上可以使用从 32 到 126(空格到波浪号)的任何字符 ASCII,但不能使用反斜杠。 So, no accent characters (international or extended ASCII) allowed.因此,不允许使用重音字符(国际或扩展 ASCII)。

On the other hand, I could include a entity with '@' inside its endpointId.另一方面,我可以在其 endpointId 中包含一个带有“@”的实体。 I cannot explain why you couldn't.我无法解释为什么你不能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Alexa 智能家居技能 - 需要帮助才能提出 http 请求 - Alexa Smart Home Skill - Need help to make an http request 通过事件网关异步回答 Alexa Smart Home Skill 时,如何回答 AWS Lambda? - What to answer an AWS Lambda when answering Alexa Smart Home Skill asynchronous via event gateway? 如何在 AWS Lambda 中的 Alexa 智能家居技能下向已发现的设备添加新操作/功能? - How to add new actions/capabilities to an already discovered device under Alexa's Smart Home Skill in AWS Lambda? 是否可以通过编程方式创建Alexa智能家居组并根据发现的设备对其进行预填充? - Is there a way to create an Alexa smart home group and pre-populate it based on discovered devices, programatically? alexa 技能中 Node.js 中的 post 请求问题 - Problem with post request in Node.js in alexa skill 如何解决 Alexa 开发人员控制台中“请求的技能响应存在问题” - How to solve "There was a problem with the requested skill's response" in Alexa Developer Console 返回响应后的响应的Alexa技能问题 - Alexa skill problem with response after response is already returned 解析 Amazon Alexa Smart Home JSON 架构时出现意外错误 - Unexpected error parsing Amazon Alexa Smart Home JSON schema 我正在尝试执行 Alexa 技能,但她说请求的技能响应有问题 - I'm trying to do a Alexa Skill, but she says There was a problem with the requested Skill's response 为Alexa APL智能显示设备设置背景颜色 - Set background color for Alexa APL smart display devices
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM