Search code examples
node.jsgoogle-smart-home

How does Google Home organize a "multi-function" device?


How does Google Home organize devices like a 3 gang light switch? Does it treat it like 3 different devices? Another example will be an IR emitter, like a universal remote control that is able to control A/C, DVD, TV...

I ask this because the device ID (in the response intent) will be the same. I don't know how to organize the traits and names. Thanks for any advice.


Solution

  • The smart home API does not have a way to uniquely identify each switch if you bundle them together as a single device. You should organize them as distinct devices, each with a unique device id, containing the OnOff trait.

    If your cloud service represents the device internally with a single identifier, you will need to generate unique ids to send Google. For example, you could append a suffix:

    {
      "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
      "payload": {
        "agentUserId": "1836.15267389",
        "devices": [
          {
            "id": "someswitch-1",
            "type": "action.devices.types.SWITCH",
            "traits": ["action.devices.traits.OnOff"],
            ...
          },
          {
            "id": "someswitch-2",
            "type": "action.devices.types.SWITCH",
            "traits": ["action.devices.traits.OnOff"],
            ...
          },
          {
            "id": "someswitch-3",
            "type": "action.devices.types.SWITCH",
            "traits": ["action.devices.traits.OnOff"],
            ...
          }
        ]
      }
    }