Automations are a way to automate tasks and device settings in a home.
Automations have been available in the Google Home ecosystem as Routines in the
Google Home app (GHA) and through the automation script editor on
Google Home for web.

Now, Automations in the Google Home ecosystem are available through the Home
APIs for Android. They use the same basic concepts used in
GHA Routines and the script editor, but with
enhanced features and capabilities only possible through the Home APIs,
including:

- Access to all Matter standard and smart home traits for a device, as presented in the Home APIs.
- Support for sequential, parallel, and select execution flows.

Automations are written using Automation DSL, a domain-specific language
designed for building automations in Kotlin.
| **Note:** Automation API supports most traits in the Home APIs, but support may be limited to specific attributes, events, and commands for a given trait. See [Automation API trait support on Android](https://developers.home.google.com/apis/android/automation/supported-traits) for more details.

Any traits and types that you intend to use in your app with the Device \&
Structure or Automation APIs must be registered at initialization. See
[Initialize the home on Android](https://developers.home.google.com/apis/android/initialize).

## Guidance if user revokes full permissions

If the user revokes full permissions, all existing automations will
stop working. Also, if the user revokes access to specific devices, then
starters, conditions, and actions associated with those devices will
stop working.

**Each time the app starts, be sure to check that the permissions
are still in effect. If they have been revoked, then be sure that all previous
data are removed, including any data cached in the application.**

## Developer journey

The Automation API is one portion of a larger development journey. It comes
after integrating the Structure and Device APIs to ensure that when a user wants
to use an automation, they can do so.

1. The developer plans their automation, and defines it using the Automation DSL.
2. The developer embeds the automation definition in a Kotlin Android app.
3. The app presents automations to a user based on information about their devices, including traits, attributes, commands, and events, gathered using the Discovery API or Device API.
   1. With the Discovery API, the app can generate a draft automation customized to the device types and traits present in the user's structure, with or without the user's input.
   2. The Device API can provide most of the same information as the Discovery API, but it's not optimized for automation use cases. See [Compare the Device API and Discovery API](https://developers.home.google.com/apis/automation/discovery#compare_the_device_api_and_discovery_api) for more details.
4. The app creates the actual automation that is keyed to the selected structure.
5. The automation is now available in the user's structure and can be executed or deleted using Structure API methods.

The user may create new instances of the automation at any time, selecting a
different structure or, depending on the app logic, perhaps a different set of
devices. Each time they do so, the app generates a new instance of the
automation.

In the most basic scenario, you might suggest to your users a predefined
automation that performs a relatively basic task. Alternatively, you could
present a skeleton of an automation that the user customizes to meet their
needs. Or you could write an open-ended automation editor that allows the user
to construct complex automations using all the building blocks available in the
Automation API.

## Resource Limits

The following limits apply to automations in the Home APIs:

| Metric | Limit |
|---|:---:|
| Maximum number of automations per structure | 64 |
| Maximum number of nodes per automation | 128 |
| Maximum number of expression nodes per automation | 64 |
| Maximum number of automation instances per structure | 1024 |
| Maximum number of automation instances per developer per structure | 64 |
| Maximum number of executions per structure per day | 1024 |
| Maximum number of executions per developer per structure per day | 128 |
[*Table: Automation API resource limits*]

| **Note:** These limits are the current defaults, and are subject to change by Google.