> Documentation index: https://developers.home.google.com/automations/schema/llms.txt

<br />

The `automations` Struct is the core of an automation script. This is where the
automation behavior is specified, including starters, conditions, and actions.
Collectively these are also referred to as an automation **rule**.

An `automations` Struct contains one or more automation rules, and each rule
always contains a set of starters and actions. A rule may optionally contain
conditions, which are additional qualifiers that must be in place in order for
the script to be executed.

| **Key** | **Type** | **Description** |
|---|---|---|
| `name` | *[String](https://developers.home.google.com/automations/schema/basics.md.txt#string)* | Optional Name of the automation. This is not shown to users, it is for developer reference only. |
| `starters` | *\[[Starter](https://developers.home.google.com/automations/schema/reference/standard/starter.md.txt)\]* | Required A list of starters. |
| `condition` | *[Condition](https://developers.home.google.com/automations/schema/reference/standard/condition.md.txt)* | Optional Condition |
| `actions` | *\[[Action](https://developers.home.google.com/automations/schema/reference/standard/action.md.txt)\]* | Required A list of actions |

## Examples

Following are two introductory examples of `automations` Structs.

In the first example, the automation is started when a
[`TV`](https://developers.home.google.com/cloud-to-cloud/guides/tv.md.txt) named "My TV" is turned on.

Once triggered, the following actions are performed:

Two [`LIGHT`](https://developers.home.google.com/cloud-to-cloud/guides/light.md.txt)
devices, named "Light A" and "Light B", are turned on and set to
brightness level 50.

```yaml
automations:
- name: Dim the lights
  starters:
  - type: device.state.OnOff
    device: My TV - Living Room
    state: on
    is: true
  actions:
  - type: device.command.OnOff
    devices:
    - Light A - Living Room
    - Light B - Living Room
    on: true
  - type: device.command.BrightnessAbsolute
    devices:
    - Light A - Living Room
    - Light B - Living Room
    brightness: 50
```

In the second example, the same automation is started at sunset each
Monday and Thursday:

```yaml
automations:
- name: Dim the lights
  starters:
  - type: time.schedule
    at: SUNSET
    weekday:
    - MONDAY
    - THURSDAY
    state: on
    is: true
  actions:
  - type: device.command.OnOff
    devices:
    - Light A - Living Room
    - Light B - Living Room
    on: true
  - type: device.command.BrightnessAbsolute
    devices:
    - Light A - Living Room
    - Light B - Living Room
    brightness: 50
```

## Starters

The [Starter](https://developers.home.google.com/automations/schema/reference/standard/starter.md.txt) Struct is where you specify the starters that cause the
Automation script to be executed. Each `automation` may contain one or more starters, and at least one starter must evaluate to `true` for subsequent conditions to be evaluated.

An example of a `time.schedule` starter:

```yaml
type: time.schedule
at: sunrise+30min
weekdays:
- MON
- TUE
```

An example of a starter on device state changes:

```yaml
type: device.state.Volume
device: My TV - Living Room
state: currentVolume
greaterThan: 1
lessThan: 10
```

An example of a starter on a device event:

```yaml
type: device.event.DoorbellPress
device: My doorbell - Frontdoor
```

An example of a starter on home presence mode changes:

```yaml
type: home.state.HomePresence
state: homePresenceMode
is: HOME
```

[View the full list of starters](https://developers.home.google.com/automations/schema/reference/standard/starter.md.txt).

## Condition

Conditions can be combined with logical operators `and`, `or`, and `not` to
express more complex logic.

In the following example, there is a `condition` Struct with one `time`
condition and one `device.state` condition. This Struct allows the script to
run if it's between sunset and sunrise on a Monday or Tuesday, or, if the TV
volume is between 1 and 10:

```yaml
type: or
conditions:
- type: time.between
  before: sunrise
  after: sunset
  weekdays:
  - MON
  - TUE
- type: device.state
  device: My TV - Living Room
  trait: Volume
  state: currentVolume
  greaterThanOrEqualTo: 1
  lessThanOrEqualTo: 10

```

A basic `time` condition example that limits execution of an Automation script
to weekends before 10:00 in the morning:

```yaml
type: time.between
before: 10am
weekdays:
- SAT
- SUN
```

A thermostat device sensor temperature condition:

```yaml
type: device.state.TemperatureSetting
device: My Thermostat - Living Room
state: thermostatTemperatureAmbient
greaterThan: 65F
```

An example of a `home.state.HomePresence` condition:

```yaml
type: home.state.HomePresence
state: homePresenceMode
is: AWAY
```

[View the full list of conditions](https://developers.home.google.com/automations/schema/reference/standard/condition.md.txt).

## Actions

Like starters and conditions, each action has a `type` which indicate what kind
of action is being specified.

The most important and the
most useful ones are the `device.command` command types. An action example of turning off lights.

```yaml
type: device.command.OnOff
devices:
- Light A - Living Room
on: false
```

An action to add a delay between multiple other actions.

```yaml
type: time.delay
for: 5min
```

[View the full list of the actions](https://developers.home.google.com/automations/schema/reference/standard/action.md.txt).