actions-on-googlegoogle-smart-home

Local Fulfilment with multiple devices


I try to create a Google Home Action with Local Fulfilment and with multiple devices that are detected through mDNS.

As such, I have a GCloud Fulfillment Function that returns the required sync:

    response.payload.devices.push({
        id: "elgato-device-id",
        name: {
          name: "Elgato",
        },
        "otherDeviceIds": [{
          "deviceId": "local-elgato-device-id"
        }],
        // ...
      });

As well as my Javascript file to handle the local part:

.onIdentify((request) => {
    const device = request.inputs[0].payload.device;
    return new Promise((resolve, reject) => {
        const response = {
            intent: smarthome.Intents.IDENTIFY,
            requestId: request.requestId,
            payload: {
                device: {
                    id: device.id || "",
                    verificationId: "local-elgato-device-id"
                },
            },
        };
        resolve(response);
    });
})

(I am using https://github.com/sirdarckcat/sirdarckcat.github.io/tree/master/fakeauth as a starting point.)

When debugging my app, I can see that onIdentify is correctly called twice, once with each of my two devices. Still, only one device appears in the Google Home app and manipulating that one will randomly control either of both physical devices.

https://developers.home.google.com/local-home/fulfillment-app says:

Note: The verificationId must match one of the otherDeviceIds in your SYNC response, in order for the Local Home platform to know it’s the same device (this process is called deduplication).

Is it possible to have multiple devices with the same deviceId? Or do I have to implement this differently? If so, how?

(I didn't consider to implement a hub yet, since https://stackoverflow.com/a/66031681 states that the Local Fulfilment SDK "uniquely identify the device by their network address" which is true for the two devices.)


Solution

  • When integrating Google Home you will need to have a unique device id for each of your devices. You can learn more about Local Fulfillment by going through Enable Local Fulfillment for Smart Home Actions Codelab.