Support device discovery

A local fulfillment path is established when Google matches a locally-controllable device to a device returned in the SYNC response from your cloud fulfillment.

To enable Google to discover your device on the local network and establish the local fulfillment path, you need to add discovery information in the Actions console. You also need to update the SYNC response from your cloud fulfillment to let Google know about the locally-controllable device.

Set up the scan config information

To specify the discovery information, follow these steps:

  1. Open your smart home project in the Actions console.
  2. In the left navigation, click Actions.
  3. Under Configure local home SDK (optional) > Add device scan configuration, click New scan config.
  4. Select a scan matching protocol type from the drop-down and enter values for Google to scan.

The following tables show the attributes you can add, based on the protocols you want Google to use to scan for your device:

mDNS
Attribute Description Example Value
Service Name Required. Service name published by the device in the format service.domain. _http._tcp.local
Name

Required. Filter for a unique service instance in the format instance.service.domain.

The platform treats this value as a regular expression and returns any matching devices.
my-device-[0-9]{4}\._http\._tcp\.local
UPnP
Attribute Description Example Value
Service Type Required. Fully qualified identifier of the UPnP service in the format domain:service:type:version. schemas-upnp-org:service:SwitchPower:1
OUI

Optional. Organizationally Unique Identifier.

24-bit value identifying the device manufacturer. Typically, the first three octets of the device MAC address.
1A:2B:3C
UDP
Attribute Description Example Value
Broadcast Address Required. Destination IP address for the UDP broadcast. 255.255.255.255
Broadcast Port Required. Destination port for the UDP broadcast. 5555
Listen Port Required. Listen port for the UDP discovery response. 5556
Discovery Packet

Required. Payload to send in the UDP broadcast.

Formatted as a hexadecimal encoded string of bytes.
48454C4C4F

Update SYNC response in the cloud fulfillment

The SYNC intent reports to Assistant what devices the user controls and their capabilities.

To support local fulfillment, the Local Home platform checks the SYNC response from your smart home Action’s cloud fulfillment and tries to match the device IDs in the otherDeviceIds field to the verification ID returned by the IDENTIFY handler. Device entries without an otherDeviceIds field are excluded from local fulfillment.

In the otherDeviceIds field of the SYNC response, you need to set the device IDs of smart home devices that can be locally controlled. The field appears at the device level in the response. Google can establish a local fulfillment path on any device with the given ID.

Use the customData field to specify any additional data Google needs to connect to a standalone device, or to target end devices via a hub (for example, the port number and other protocol-specific information).

Example

The following snippet shows how you might create your SYNC handler.

Standalone/Hub
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "payload": {
    "agentUserId": "1836.15267389",
    "devices": [{
      "id": "123",
      "type": "action.devices.types.OUTLET",
      "traits": [
        "action.devices.traits.OnOff"
      ],
      "name": {
        "name": "Night light"
      },
      "willReportState": false,
      "otherDeviceIds": [{
        "deviceId": "local-device-id"
      }],
      "customData": {
        "port": 5555,
        "authToken": "..."
      }
    }]
  }
}