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:
- Write scripted automations with the script editor
- Complete list of supported starters, conditions, and actions
- List of supported devices
- Visit our codelab for a guided example of creating your first script.
- Additional practice for writing a scripted automation and example scripts.
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 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
Each pair is indented by 2 spaces to show it's a child of the key |
|
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: |
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.
Create a scripted automation
With the Google Home app
- Open the Google Home app .
- Tap Automations .
- Tap Add Household More options Script editor.
- Draft your new scripted automation. Refer to Write scripted automations with the script editor for help structuring your script.
- Tap Validate to verify your script runs. You can't activate an automation with errors.
- 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
-
Open home.google.com/automations and sign in to your account.
-
Click Add new.
- Draft your new scripted automation. Refer to Write scripted automations with the script editor for help structuring your script.
- Click Validate to verify your script is able to run. You can't activate an automation with errors.
- 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
- Open the Google Home app .
- Tap Automations the name of your scripted automation Edit.
- Edit your scripted automation.
- Tap Validate to verify your script is able to run. You can't activate an automation with errors.
- 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.
With Google Home for web
-
Open home.google.com/automations and sign in to your account.
- Select your scripted automation.
- Edit your script.
- Click Validate to verify your script is able to run. You can't activate an automation with errors.
- 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
- Open the Google Home app .
- Tap Automations .
- Select the Routine you want to delete.
- Tap Delete Delete routine.
With Google Home for web
-
Open home.google.com/automations and sign in to your account.
- Click your scripted automation .
- 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.
- Make sure you use the correct device name in the format
- If the script saves, but the automation doesn't behave as expected or stops working, 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. Note: Manufacturers may change device traits when they perform updates and this can cause scripts to stop working. You can use auto-complete to help update affected scripts.
- 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.