Join us online for the "Hey Google" Smart Home Summit on July 8th! Register here to learn what's new, and what's coming up for Google Smart Home.

Smart Home Faucet Guide

Device TYPE

action.devices.types.FAUCET Faucets can dispense liquids in various quantities and presets.

Faucets may have various modes and each mode has its own related settings. These are specific to the faucet and are interpreted in a generalized form.

This type indicates that the device gets the faucet icon and some synonyms/aliases.

These traits are recommended, if applicable to your device. However, you are free to mix and match from all available traits to best match your existing product functionality.

Sample SYNC Request and Response

This is an example using the device type and traits above. It is intended to give an idea of how to build a SYNC response. If you add or remove traits, this will need to be modified to reflect those changes.

Request
{
    "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
    "inputs": [{
      "intent": "action.devices.SYNC"
    }]
}
Node.js
'use strict';

const {smarthome} = require('actions-on-google');
const functions = require('firebase-functions');

const app = smarthome();

app.onSync((body, headers) => {
  return {
    requestId: body.requestId,
    payload: {
      agentUserId: '1836.15267389',
      devices: [{
        id: '123',
        type: 'action.devices.types.FAUCET',
        traits: [
          'action.devices.traits.Dispense'
        ],
        name: {
          defaultNames: [
            'Faucet'
          ],
          name: 'Sink Faucet',
          nicknames: [
            'Faucet'
          ]
        },
        willReportState: true,
        attributes: {
          supportedDispenseItems: [{
            item_name: 'water',
            item_name_synonyms: [{
              lang: 'en',
              synonyms: ['water']
            }, {
              lang: 'es',
              synonyms: ['agua']
            }, {
              lang: 'fr',
              synonyms: ['eau']
            }],
            supported_units: [
              'TEASPOONS',
              'TABLESPOONS',
              'FLUID_OUNCES',
              'CUPS',
              'PINTS',
              'QUARTS',
              'GALLONS',
              'MILLILITERS',
              'LITERS',
              'DECILITERS'
            ],
            default_portion: {
              amount: 2.0,
              unit: 'CUPS'
            }
          }],
          supportedDispensePresets: [{
            preset_name: 'cat water bowl',
            preset_name_synonyms: [{
              lang: 'en',
              synonyms: [
                'cat water bowl',
                'cat water dish',
                'cat water cup'
              ]
            }, {
              lang: 'es',
              synonyms: [
                'plato de agua para gato',
                'bebedero para gato'
              ]
            }, {
              lang: 'fr',
              synonyms: [
                `bol d'eau de chat`,
                'bac à eau pour chat',
                `tasse d'eau de chat`
              ]
            }]
          }]
        },
        customData: {
          fooValue: 42,
          barValue: true,
          catValue: "Fuzzy"
        }
      }]
    }
  };
});

// ...

exports.smarthome = functions.https.onRequest(app);
Java
@NotNull
@Override
public SyncResponse onSync(@NotNull SyncRequest syncRequest, @Nullable Map<?, ?> headers) {
  SyncResponse.Payload payload = new SyncResponse.Payload();
  payload.setAgentUserId("123456789");
  payload.setDevices(
      new SyncResponse.Payload.Device[] {
        new SyncResponse.Payload.Device.Builder()
            .setId("123")
            .setType("action.devices.types.FAUCET")
            .addTrait("action.devices.traits.Dispense")
            .setName(
                Collections.singletonList("Faucet"),
                "Sink Faucet",
                Collections.singletonList("Faucet"))
            .setWillReportState(true)
            .setAttributes(
                new JSONObject()
                    .put(
                        "supportedDispenseItems",
                        new JSONObject[] {
                          new JSONObject()
                              .put("item_name", "water")
                              .put(
                                  "item_name_synonyms",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put("lang", "en")
                                        .put("synonyms", new String[] {"water"}),
                                    new JSONObject()
                                        .put("lang", "es")
                                        .put("synonyms", new String[] {"agua"}),
                                    new JSONObject()
                                        .put("lang", "fr")
                                        .put("synonyms", new String[] {"eau"})
                                  })
                              .put(
                                  "supported_units",
                                  new String[] {
                                    "TEASPOONS",
                                    "TABLESPOONS",
                                    "FLUID_OUNCES",
                                    "CUPS",
                                    "PINTS",
                                    "QUARTS",
                                    "GALLONS",
                                    "MILLILITERS",
                                    "LITERS",
                                    "DECILITERS"
                                  })
                              .put(
                                  "default_portion",
                                  new JSONObject().put("amount", 2.0).put("unit", "CUPS"))
                        })
                    .put(
                        "supportedDispensePresets",
                        new JSONObject[] {
                          new JSONObject()
                              .put("preset_name", "cat water bowl")
                              .put(
                                  "preset_name_synonyms",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put("lang", "en")
                                        .put(
                                            "synonyms",
                                            new String[] {
                                              "cat water bowl", "cat water dish", "cat water cup"
                                            }),
                                    new JSONObject()
                                        .put("lang", "es")
                                        .put(
                                            "synonyms",
                                            new String[] {
                                              "plato de agua para gato", "bebedero para gato"
                                            }),
                                    new JSONObject()
                                        .put("lang", "fr")
                                        .put(
                                            "synonyms",
                                            new String[] {
                                              "bol d'eau de chat",
                                              "bac à eau pour chat",
                                              "tasse d'eau de chat"
                                            })
                                  })
                        }))
            .setDeviceInfo("Sirius Cybernetics Corporation", "492134", "3.2", "11.4")
            .setCustomData(
                new JSONObject()
                    .put("fooValue", 42)
                    .put("barValue", true)
                    .put("catValue", "Fuzzy")
                    .toString())
            .build()
      });

  return new SyncResponse(syncRequest.getRequestId(), payload);
}
JSON
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "payload": {
    "agentUserId": "1836.15267389",
    "devices": [
      {
        "id": "123",
        "type": "action.devices.types.FAUCET",
        "traits": [
          "action.devices.traits.Dispense"
        ],
        "name": {
          "defaultNames": [
            "Faucet"
          ],
          "name": "Sink Faucet",
          "nicknames": [
            "Faucet"
          ]
        },
        "willReportState": true,
        "attributes": {
          "supportedDispenseItems": [
            {
              "item_name": "water",
              "item_name_synonyms": [
                {
                  "lang": "en",
                  "synonyms": [
                    "water"
                  ]
                },
                {
                  "lang": "es",
                  "synonyms": [
                    "agua"
                  ]
                },
                {
                  "lang": "fr",
                  "synonyms": [
                    "eau"
                  ]
                }
              ],
              "supported_units": [
                "TEASPOONS",
                "TABLESPOONS",
                "FLUID_OUNCES",
                "CUPS",
                "PINTS",
                "QUARTS",
                "GALLONS",
                "MILLILITERS",
                "LITERS",
                "DECILITERS"
              ],
              "default_portion": {
                "amount": 2,
                "unit": "CUPS"
              }
            }
          ],
          "supportedDispensePresets": [
            {
              "preset_name": "cat water bowl",
              "preset_name_synonyms": [
                {
                  "lang": "en",
                  "synonyms": [
                    "cat water bowl",
                    "cat water dish",
                    "cat water cup"
                  ]
                },
                {
                  "lang": "es",
                  "synonyms": [
                    "plato de agua para gato",
                    "bebedero para gato"
                  ]
                },
                {
                  "lang": "fr",
                  "synonyms": [
                    "bol d'eau de chat",
                    "bac à eau pour chat",
                    "tasse d'eau de chat"
                  ]
                }
              ]
            }
          ]
        },
        "customData": {
          "fooValue": 42,
          "barValue": true,
          "catValue": "Fuzzy"
        }
      }
    ]
  }
}
Validator

Device ERRORS

See the full list of errors and exceptions.