0

I am trying to implement Local Fulfillment in my Google Smart Home Action. some of my devices have 2 channels (dual relay switch).
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.

I have added customData and otherDevicesIds to my SYNC response to enable local fultilment and built an local app using @google/local-home-sdk. Google Home identifies Single channel devices and sends commands locally.

example of SYNC response body:

{
    "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. Google ignores one of them. Looks like it is not possible to have 2 devices with same IP address.

Here is the IDENTIFY request body:

{
    "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:

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?

fdistorted
  • 343
  • 3
  • 15
  • can you update your question w/ the current `IdentifyRequest` (if any) you get in your typescript app? and what you return as an `IdentifyResponse` for both devices? (and if you get additional logging/error from the SDK). – proppy Feb 03 '21 at 11:29
  • @proppy I've added JSONs as you asked. As I see in typescript class definition there is no way to send a few devices in a single IDENTIFY response. And there is a `udpScanData` only for `_0` channel. There is an option to represent my multichannel device as a hub but I'm not sure how to work with it further. – fdistorted Feb 03 '21 at 12:05
  • app for hub devices can respond to `REACHEABLE_DEVICES` intend to specify more than one device to verify, see https://developers.google.com/assistant/smarthome/develop/local#implement_the_reachable_devices_handler_hub_integrations_only – proppy Feb 03 '21 at 14:15
  • in this case, are you able to return a single broadcast response for the whole device rather than one by channel? – proppy Feb 03 '21 at 14:19
  • @proppy yes. I am able to return a response for the whole device. Should I use hub feature? – fdistorted Feb 03 '21 at 15:14
  • yes, let me answer the question properly. – proppy Feb 03 '21 at 16:21

1 Answers1

1

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.

You can however have one device acting as a proxy for multiple end-devices, this is done by:

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

proppy
  • 10,495
  • 5
  • 37
  • 66