【问题标题】:How to handle IDENTIFY request in Google Smart Home Local Fulfilment for multi channel device?如何处理多通道设备的 Google Smart Home Local Fulfillment 中的 IDENTIFY 请求?
【发布时间】:2023-03-21 19:42:02
【问题描述】:

我正在尝试在我的 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 个具有上述不同 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


【解决方案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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多