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

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

我正在尝试在我的 Google Smart Home Action 中实施 Local Fulfillment。 我的一些设备有 2 个通道(双继电器开关)。
双通道设备在 Google Home 应用程序中显示为两个独立的设备(light-test123123_0light-test123123_1)并且工作正常。

我已将 customDataotherDevicesIds 添加到我的 SYNC 响应中以启用本地实现并使用 @google/local-home-sdk 构建本地应用程序。 Google主页识别单通道设备并在本地发送命令。

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数据包,上面提到的。 Google 忽略其中之一。看起来不可能有 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

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

有办法解决这个问题吗?

Local Fulfillment 平台目前(自 Local Home SDK 1.4 起)通过网络地址唯一标识设备,因此它无法处理来自同一物理连接设备的多个广播响应。

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

Local Home SDK sample 包含一个可以运行 在此配置中的虚拟设备: https://github.com/actions-on-google/smart-home-local#set-up-the-virtual-device