繁体   English   中英

如何在 Google Smart Home Local Fulfillment 中处理多通道设备的 IDENTIFY 请求?

[英]How to handle IDENTIFY request in Google Smart Home Local Fulfilment for multi channel device?

我正在尝试在我的 Google 智能家居操作中实施本地履行。 我的一些设备有 2 个通道(双继电器开关)。
双通道设备在 Google Home 应用程序中显示为两个独立的设备( light-test123123_0light-test123123_1 ),它工作得很好。

我已将customDataotherDevicesIds添加到我的 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 个单独的 UDP 数据包,具有上述不同的 ID。 谷歌忽略了其中之一。 看起来不可能有 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

这显示了我的设备在接收到广播数据包时的行为。

有没有办法来解决这个问题?

当前的本地履行平台(从本地主页 SDK 1.4 开始)通过设备的网络地址唯一地识别设备,因此它无法处理来自同一物理连接设备的多个广播响应。

但是,您可以让一个设备充当多个终端设备的代理,这是通过以下方式完成的:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM