【发布时间】:2023-03-21 19:42:02
【问题描述】:
我正在尝试在我的 Google 智能家居操作中实施本地配送。
我的一些设备有 2 个通道(双继电器开关)。
双通道设备在 Google Home 应用程序中显示为两个独立的设备(light-test123123_0 和 light-test123123_1),它工作得很好。
我已将 customData 和 otherDevicesIds 添加到我的 SYNC 响应中以启用本地履行并使用 @google/local-home-sdk 构建本地应用程序。 Google Home 识别单通道设备并在本地发送命令。
SYNC 响应正文示例:
{
"response": {
"payload": {
"devices": [
{
"traits": [
"action.devices.traits.OnOff",
"action.devices.traits.Brightness"
],
"customData": {
"path": "/local-fulfil/0/",
"port": 3000
},
"name": {
"name": "light",
"nicknames": [
"light"
],
"defaultNames": [
"light"
]
},
"id": "light-test123123_0",
"type": "action.devices.types.LIGHT",
"deviceInfo": {
"hwVersion": "LIGHT",
"model": "LIGHT",
"swVersion": "1.0",
"manufacturer": "MANUFATURER"
},
"attributes": {},
"willReportState": false,
"otherDeviceIds": [
{
"deviceId": "light-test123123_0"
},
{
"deviceId": "light-test123123"
}
]
},
{
"name": {
"nicknames": [
"light"
],
"defaultNames": [
"light"
],
"name": "light"
},
"deviceInfo": {
"swVersion": "1.0",
"hwVersion": "LIGHT",
"manufacturer": "MANUFATURER",
"model": "LIGHT"
},
"attributes": {},
"otherDeviceIds": [
{
"deviceId": "light-test123123_1"
},
{
"deviceId": "light-test123123"
}
],
"willReportState": false,
"traits": [
"action.devices.traits.OnOff",
"action.devices.traits.Brightness"
],
"id": "light-test123123_1",
"customData": {
"port": 3000,
"path": "/local-fulfil/1/"
},
"type": "action.devices.types.LIGHT"
}
],
"agentUserId": "RuRHIPWpD5W23iGiU81A5PoTKqB2"
},
"requestId": "16772679358918515269"
}
}
当我启动本地 SDK 实现时出现问题,因为即使我的双通道设备发送了 2 个具有上述不同 ID 的单独 UDP 数据包。谷歌忽略了其中之一。看起来不可能有 2 台设备具有相同的 IP 地址。
这是 IDENTIFY 请求正文:
{
"requestId": "88DB84992F074FF0B408D8383CF198C4",
"inputs": [
{
"intent": "action.devices.IDENTIFY",
"payload": {
"device": {
"udpScanData": {
"data": "6C696768742D6475616C2D3132335F30"
}
},
"structureData": {}
}
}
],
"devices": [
{
"id": "light-dual-123_0",
"customData": {
"path": "/local-fulfil/0/",
"port": 3000
}
},
{
"id": "light-dual-123_1",
"customData": {
"path": "/local-fulfil/1/",
"port": 3000
}
}
]
}
和回应:
{
"intent": "action.devices.IDENTIFY",
"requestId": "88DB84992F074FF0B408D8383CF198C4",
"payload": {
"device": {
"id": "",
"verificationId": "light-test123123_0"
}
}
}
我编写了一个发送 UDP 广播并输出下一个数据的基本应用程序:
sent broadcast packet
192.168.1.235:8888 sent this: light-test123123_0
192.168.1.235:8888 sent this: light-test123123_1
这显示了我的设备在接收到广播数据包时的行为。
有没有办法解决这个问题?
【问题讨论】:
-
你能用你在打字稿应用程序中得到的当前
IdentifyRequest(如果有的话)更新你的问题吗?以及您为这两种设备返回的IdentifyResponse是什么? (如果您从 SDK 获得额外的日志记录/错误)。 -
@proppy 我已经按照你的要求添加了 JSON。正如我在打字稿类定义中看到的那样,无法在单个 IDENTIFY 响应中发送几个设备。还有一个
udpScanData仅用于_0频道。有一个选项可以将我的多通道设备表示为集线器,但我不确定如何进一步使用它。 -
app for hub设备可以回复
REACHEABLE_DEVICES打算指定多个设备进行验证,见developers.google.com/assistant/smarthome/develop/… -
在这种情况下,您是否能够为整个设备返回单个广播响应,而不是按频道返回?
-
@proppy 是的。我能够返回整个设备的响应。我应该使用集线器功能吗?
标签: iot actions-on-google google-smart-home