Nick Felker
Jun 27 · 5 min read

After moving to New York and settling into an apartment a few months ago, I started to think of ways to incorporate automation into my new home. Naturally, I ended up getting some Google Assistant-enabled smart home devices! What attracted me was the convenience of being able to control these devices individually with a voice command.

With the Assistant, I can leverage a broad ecosystem of devices, by creating routines to control multiple devices at a time. (Nothing beats saying “I’m home” to simultaneously turn on the kitchen lights and start playing music even while my hands are full with groceries!) The Assistant lets me easily schedule routines to happen at certain days and times — devices are activated on my behalf without a verbal command. Now when I leave for work every morning, my smart vacuum turns on and I return later that day to a clean home.

If you are a home automation developer building an IoT device, or want to connect an existing IoT device to the Google Assistant, here are some best practices.

Straight to the point

Many Actions are conversational, invoked by including “talk to …” in your query. These are built using tools like Dialogflow, where you manually craft a set of user phrases and determine how to respond to them. As the conversational Action gains more users, you will need to continually update the user phrases to make sure you handle a variety of use cases. As these users grow internationally, you’ll have to maintain this project across different languages.

In contrast, by building a smart home Action, you enable users to directly control their device with voice commands. The Assistant also allows users to control devices from multiple smart device providers at the same time (e.g. “turn off all my lights”). This is because their devices are stored in the Home Graph, a database that stores and provides contextual data about the home and its devices.

The benefits can extend beyond voice: if a user’s device is a camera, light, outlet, switch, or thermostat, they can see a visual interface on their phone and on smart displays.

An example of touch controls that group together two lights in the bedroom

Define your device with a type and trait(s)

When building a smart home Action, you categorize your device under a specific type. The device type is used for semantic purposes. For example, specifying that your device is a LIGHT type means that it will be activated when the user gives commands about lights. When two lights are in the same room, they can be grouped together for quicker access.

Each type is associated with a list of traits that declare the device capabilities to the Assistant. By default, users can query traits for the current state and send control commands to update them. For devices that only support one-way behavior for a given trait, such as a sensor, the queryOnly and commandOnly attributes enforce this constraint. Device traits requiring additional security can incorporate two-factor authentication, which enables you to request a simple confirmation or a PIN before the request is accepted.

Types and traits enable you to focus on the device capabilities and let Google handle the conversation elements. Device traits are deeply integrated with Google’s natural language understanding with grammars that allow user queries and commands in each of the supported languages, including any additional languages we may support in the future.

If you are unable to express your device’s behavior using the currently available set of pre-defined traits, you may be able to describe it using modes and toggles instead. The Modes trait describes attributes of your device that have discrete settings. For example, a washer could define a mode named “load” with the settings “small,” “medium,” and “large”. Toggles are similar, but only support the binary states on or off.

You can see the complete list of available modes and available toggles in our reference documentation. To request a new mode or toggle attribute, create a new issue on the smart home GitHub repository. If your device requires a trait behavior that we don’t currently support, request a new trait by filling out this form. The smart home team regularly adds support for new types and traits.

Provide deeper integration into the state of your devices

By integrating with the smart home platform, you are able to provide deep integrations to ensure your home is running effectively and securely.

When your device isn’t working, your Action can return one of a set of errors which provides users with a verbal error message that clearly explains the issue. For example, if your smart vacuum is stuck in a corner and you want it to start cleaning, it can return the error “deviceStuck”. If you say “start cleaning,” the Google Assistant will respond with “The vacuum is stuck.” This lets the user know that the vacuum needs to be found and rescued.

If the smart vacuum’s battery is getting low, but can still complete cleaning, it can return an exception instead. A non-blocking exception indicates that your command succeeded, but there’s some additional piece of information that you should know. In this example, it may return a non-blocking exception with the status code “lowBattery”. The Google Assistant will respond with a message like, “Okay, starting the vacuum. By the way, the vacuum has a low battery”.

Like with the traits, these verbal responses are translated and available in the dozen languages currently supported. This saves you a lot of time in making your smart home devices available in more places around the world.

Users can combine several of these tasks into a single routine. Saying “I’m home” can cause several different devices to turn on or execute another configurable action through the Google Assistant settings.

The home of the future

The home of the future is one that is further connected between the devices a user has in their home. We invite you to help us get to this future by connecting your devices to this broad ecosystem. With a smart home Action, you can take advantage of built-in features of the platform: touch controls, i18n, errors and exceptions, and two-factor authentication.

The smart home team here at Google is continuing to work on adding new device types and traits. Let us know if there’s a use-case that’s not supported yet.

If you want to build a smart home Action and don’t know where to start, get started by reading our documentation and check out our smart home codelab!


Want more? Head over to the Actions on Google community to discuss Actions with other developers. Join the Actions on Google developer community program and you could earn a $200 monthly Google Cloud credit and an Assistant t-shirt when you publish your first app.

Google Developers

Engineering and technology articles for developers, written and curated by Googlers. The views expressed are those of the authors and don't necessarily reflect those of Google.

Nick Felker

Written by

Social Media Expert -- Rowan University 2017 -- IoT & Assistant @ Google

Google Developers

Engineering and technology articles for developers, written and curated by Googlers. The views expressed are those of the authors and don't necessarily reflect those of Google.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade