[英]How to handle IDENTIFY request in Google Smart Home Local Fulfilment for multi channel device?
I am trying to implement Local Fulfillment in my Google Smart Home Action.我正在尝试在我的 Google 智能家居操作中实施本地履行。 some of my devices have 2 channels (dual relay switch).
我的一些设备有 2 个通道(双继电器开关)。
Dual channel device is shown in Google Home app as two separate devices( light-test123123_0
and light-test123123_1
) and it works just fine.双通道设备在 Google Home 应用程序中显示为两个独立的设备(
light-test123123_0
和light-test123123_1
),它工作得很好。
I have added customData
and otherDevicesIds
to my SYNC response to enable local fultilment and built an local app using @google/local-home-sdk
.我已将
customData
和otherDevicesIds
添加到我的 SYNC 响应中以启用本地实现并使用@google/local-home-sdk
构建本地应用程序。 Google Home identifies Single channel devices and sends commands locally. Google Home 识别单通道设备并在本地发送命令。
example of SYNC response body: 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"
}
}
The problems appeared when I have started the local SDK implementation because even if my dual channel device sends 2 separate UDP packets with different IDs mentioned above.当我启动本地 SDK 实现时出现问题,因为即使我的双通道设备发送 2 个单独的 UDP 数据包,具有上述不同的 ID。 Google ignores one of them.
谷歌忽略了其中之一。 Looks like it is not possible to have 2 devices with same IP address.
看起来不可能有 2 个具有相同 IP 地址的设备。
Here is the IDENTIFY request body:这是 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
}
}
]
}
and response:和回应:
{
"intent": "action.devices.IDENTIFY",
"requestId": "88DB84992F074FF0B408D8383CF198C4",
"payload": {
"device": {
"id": "",
"verificationId": "light-test123123_0"
}
}
}
I have written a basic app that sends UDP broadcast and it outputs the next data:我编写了一个发送 UDP 广播的基本应用程序,它输出下一个数据:
sent broadcast packet
192.168.1.235:8888 sent this: light-test123123_0
192.168.1.235:8888 sent this: light-test123123_1
That shows how my device acts when it receives a broadcast packet.这显示了我的设备在接收到广播数据包时的行为。
Is there a way to fix this?有没有办法来解决这个问题?
The Local Fulfillment platform currently (as of Local Home SDK 1.4) uniquely identify the device by their network address, so it won't be able to handle multiple broadcast response coming from the same physical connected device.当前的本地履行平台(从本地主页 SDK 1.4 开始)通过设备的网络地址唯一地识别设备,因此它无法处理来自同一物理连接设备的多个广播响应。
You can however have one device acting as a proxy for multiple end-devices, this is done by:但是,您可以让一个设备充当多个终端设备的代理,这是通过以下方式完成的:
isProxy
flag to true in the IDENTIFY
response: https://developers.google.com/assistant/smarthome/develop/local#hub-identifyIDENTIFY
响应中返回将isProxy
标志设置为 true: https://developers.google.com/assistant/smarthome/develop/local#hub-identifyREACHABLE_DEVICES
intent to return all the end-device verificationId
: https://developers.google.com/assistant/smarthome/develop/local#hub-identifyREACHABLE_DEVICES
意图以返回所有终端设备verificationId
ID:https://developers.google.com/assistant/smarthome/develop/local#hub-identify The Local Home SDK sample includes a virtual device that can be run in this configuration: https://github.com/actions-on-google/smart-home-local#set-up-the-virtual-device Local Home SDK 示例包括一个可以在此配置中运行的虚拟设备: https://github.com/actions-on-google/smart-home-local#set-up-the-virtual-device
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.