簡體   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