A local fulfillment path is established when Google matches a locally-controllable device
to a device returned in the [`SYNC`](https://developers.home.google.com/cloud-to-cloud/primer/intents#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. Go to your Cloud-to-cloud integration in the Google Home Developer Console:

   [Go to the Developer Console](https://console.home.google.com).
2. Go to **Project \> Cloud-to-cloud** on the left side of the screen, then
   select **Edit** for the integration.
   In the **Setup and configuration** page, scroll to **Local fulfillment**
   and toggle the setting on. Enter the following URL into each test URL field,
   insert your project ID, and click **Save**:

   `https://&lt;project-id&gt;.web.app/local-home/index.html`
3. Click **+ Add scan configuration** under **Device discovery** to add a new scan configuration.

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](http://standards-oui.ieee.org/oui/oui.txt). 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 |
|---|---|---|
| Discovery Address | Required. Destination IP address for the UDP broadcast. | `255.255.255.255` |
| Broadcasting Port | Required. Destination port for the UDP broadcast. | `5555` |
| Listening 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`](https://developers.home.google.com/cloud-to-cloud/intents/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`](https://developers.home.google.com/reference/home-graph/rest/v1/devices/sync#Device.FIELDS.other_device_ids)
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.

> [!NOTE]
> **Note:** If the local device you are integrating is a hub (or a bridge), the hub device may not be present in the `SYNC` response. Use the `otherDeviceIds` field in your `SYNC` response to represent the local device IDs for end devices connected to the hub that users can control.

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

> [!NOTE]
> **Note:** You should always use the `customData` field whenever you need to send device-specific data to a local fulfillment handler. This may include authorization tokens, encryption keys, or unique identifiers that the handler needs to successfully communicate with the device.

### 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": "..."
      }
    }]
  }
}
```