---
layout: page
title: "Automation Actions"
description: "Automations result in action."
date: 2016-04-24 08:30 +0100
sidebar: true
comments: false
sharing: true
footer: true
---

The action of an automation rule is what is being executed when a rule fires. The action part follows the [script syntax] which can be used to interact with anything via services or events. For services you can specify the entity_id that it should apply to and optional service parameters (to specify for example the brightness).

You can also call the service to activate [a scene] which will allow you to define how you want your devices to be and have Home Assistant call the right services.

[script syntax]: /getting-started/scripts/
[a scene]: /components/scene/

```yaml
automation:
  # Change the light in the kitchen and living room to 150 brightness and color red.
  trigger:
    platform: sun
    event: sunset
  action:
    service: homeassistant.turn_on
    entity_id:
      - light.kitchen
      - light.living_room
    data:
      brightness: 150
      rgb_color: [255, 0, 0]

automation 2:
  # Notify me on my mobile phone of an event
  trigger:
    platform: sun
    event: sunset
    offset: -00:30
  action:
    # Actions are scripts so can also be a list of actions
    - service: notify.notify
      data:
        message: Beautiful sunset!
    - delay: 0:35
    - service: notify.notify
      data:
        message: Oh wow you really missed something great.
```


Conditions can also be part of an action:

```yaml
automation:
- alias: 'Enciende Despacho'
  trigger:
    platform: state
    entity_id: sensor.mini_despacho
    to: 'ON'
  action:
    - condition: or
      conditions:
        - condition: template
          value_template: '{{ states.sun.sun.attributes.elevation < 4 }}'
        - condition: template
          value_template: '{{ states.sensor.sensorluz_7_0.state < 10 }}'
    - service: scene.turn_on
      entity_id: scene.DespiertaDespacho
```
