Notification

To get the most out of Google Home, choose your Help Center: U.S. Help Center, U.K. Help Center, Canada Help Center, Australia Help Center.

Create advanced home automations with the script editor

With the Google Home app, you can automate your home using Routines. To create advanced Household Routines, the script editor allows you to program scripted automations with additional starters, conditions, actions, and advanced logic.

The script editor is currently available in Public Preview. You can access the script editor with Google Home for web or in the mobile Google Home app after you've joined Public Preview.

Learn how to write scripted automations:

Visit codelab

Get started

The script editor allows you to write and edit your own Household Routines with Google Home for web or in the Google Home app.

To create scripted automations, you'll need to:

  • Understand the basics of YAML, a human-readable scripting language that allows you to enter line-by-line instructions to create home automations.
  • Understand how Routines work, including terminology like starters and actions.
  • Understand how to use the script editor to write scripted automations.

For more detailed info on how to write a script, follow Write scripted automations with the script editor.

Note: On an iPhone or iPad, you can view, edit, deactivate, and run automations in the Google Home app, but you can't currently create new scripted automations. If you have an iPhone or iPad, we recommend using Google Home for web to create new automations.

Script editor basics

The script editor uses YAML, a scripting language that allows you to enter line-by-line instructions to create home automations. Learn more at Write scripted automations with the script editor.

YAML quick reference guide

YAML Concepts Example

Key-value pairs

YAML is written as a collection of key-value pairs separated by a : and a space. Each key-value pair starts on a new line.

A key is a literal keyword. The value associated with a key can be as simple as a string, number, or date, or as complex as another collection of key-value pairs.

In the example, the Key = name and the Value = TV on lights off.

name: TV on lights off

Indentation and nested key-value pairs

You can "nest" multiple key-value pairs under a single parent key.

YAML uses indentation (2 spaces) to indicate structure and hierarchy, and to define nested elements. Each level of nesting is indented by the same number of spaces.

In the example, the parent key is metadata. The value for metadata is two nested key-value pairs:

  • Pair 1: Key = name; Value = TV on lights off

  • Pair 2: Key = description; Value = Turn off lights when TV turns on

Each pair is indented by 2 spaces to show it's a child of the key metadata.

metadata:
name: TV on lights off
description: Turn off lights when TV turns on

Multiple values

To include multiple values with a single key, create a list. Use a hyphen before each list item.

In the example, the key = weekday, and the value is a list that includes Monday and Thursday.
weekday:
- MONDAY
- THURSDAY

Comments

Lines that start with # are comments and are ignored by the automation engine.
# This is a comment. It will be ignored.

Supported starters, conditions, and actions

You'll define your automation behaviors using keys called starters, conditions, and actions:

  • Starters tell your automation when to begin. Starters can include specific times or device states. An automation can include more than one starter.
  • Conditions are restrictions on when your automation should run. Conditions are checked each time an automation begins. For example, you could specify that your automation only runs if you're away from home or if it's after sunset.
  • Actions are what your automation will do, like adjust the speaker volume or turn a light on or off.

For a complete list of starters, conditions, and actions, visit the Google Home Developer Center. Each of these components have their own set of instructions and formatting. Click on an entry in the supported starters, conditions, and actions table to find specific instructions, how to format, and example code. You can also check which of your devices are supported and which actions and commands they can use.

Create, edit, and delete scripted automations

Use the script editor in Google Home for web or the Google Home app to write and edit custom scripted automations.

Important: All household members can see when these Routines run. Routines are for convenience only, not safety- or security-critical use cases. Do not create Routines that could result in injury or harm if they fail to start or stop. Routines can depend on working internet, Wi-Fi, and service availability from both Google and the third parties who manufacture the devices included in Routines. Routines may not always work, and Google is not responsible for any harm or losses incurred as a result of any failed Routines.

Create a scripted automation

With the Google Home app

  1. Open the Google Home app Google Home app.
  2. Tap Automations .
  3. Tap Add Household More options More menu Script editor.
  4. Draft your new scripted automation. Refer to Write scripted automations with the script editor for help structuring your script.
  5. Tap Validate to verify your script runs. You can't activate an automation with errors.
  6. Tap Save to add your automation to your home or save in-progress work. If your script is valid when you save it, your automation automatically activates. If you don't want it to run yet, turn Activate off.

With Google Home for web

  1. Open home.google.com/automations and sign in to your account.
  2. Click Add new.
  3. Draft your new scripted automation. Refer to Write scripted automations with the script editor for help structuring your script.
  4. Click Validate to verify your script is able to run. You can't activate an automation with errors.
  5. Click Save to add your automation to your home or save in-progress work. If your script is valid when you save it, your automation automatically activates. If you don't want it to run yet, turn Activate off.

Edit a scripted automation

You can view and edit most automations you created with the script editor. Non-scripted automations and automations that are actively running can't be edited in the script editor. Once you've stopped an automation, you'll be able to edit it.

With the Google Home app

  1. Open the Google Home app Google Home app.
  2. Tap Automations the name of your scripted automation Edit.
  3. Edit your scripted automation.
  4. Tap Validate to verify your script is able to run. You can't activate an automation with errors.
  5. Tap Save. If your script is valid when you save it, your automation automatically activates. If you don't want it to run yet, turn Activate off.
For quick and easy access, pin your most-used devices, rooms, automations, and actions to your Favorites in the Google Home app. Learn more about creating and customizing Favorites.

With Google Home for web

  1. Open home.google.com/automations and sign in to your account.
  2. Select your scripted automation.
  3. Edit your script.
  4. Click Validate to verify your script is able to run. You can't activate an automation with errors.
  5. Click Save to add your automation to your home or save in-progress work. If your script is valid when you save it, your automation automatically activates. If you don't want it to run yet, turn Activate off.

Delete a scripted automation

Important: Deleting a Routine or automation is permanent. To stop a Routine or automation temporarily, pause it instead.

With the Google Home app

  1. Open the Google Home app Google Home app.
  2. Tap Automations .
  3. Select the Routine you want to delete.
  4. Tap Delete and then Delete routine.

With Google Home for web

  1. Open home.google.com/automations and sign in to your account.
  2. Click your scripted automation .
  3. Click Delete Delete.

Help with scripted automations

  • Find help with scripts and learn what others are working on in the Google Home Automation community.
  • For automations to work, scripts must use valid code. If an error exists, a message appears. Learn more about validation errors and warnings.
  • To validate your code, click or tap Validate in the script editor. Here are some common errors to look out for:
    • Make sure you use the correct device name in the format Device name - Room name. If you're not sure, check the name of your device in the Google Home app.
    • Make sure your device supports the function you want it to perform. You can also use auto-complete to find available options.
    • Make sure you include an action. Actions are required for an automation to run.
  • If the script saves, but the automation doesn't behave as expected, manually confirm that each component in your script works. For example, if you wrote a script to turn on the light and change the brightness at sunset, try completing these tasks with an assistant command to confirm that each individual function works. You can also check that:
    • Your device is added or linked in the Google Home app.
    • Your device is connected and online.
    • The device name, starters, conditions, and actions are written correctly.
    • Your script has proper indentation and formatting.
  • With Google Home for web, you can access Automations logs below your script to view your automation’s history and to identify potential problems. Learn more about the types of messages you see in the Automation logs.
  • Try using the script editor’s experimental generative AI feature to describe the automation you want and it will draft a script for you to review and edit.
  • Learn more about the basics of Routines and how to troubleshoot them.
  • Refer to Practice writing a first script.

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Main menu
3670328469552983749
true
Search Help Center
true
true
true
true
true
1633396
false
false