Automation Conditions

Conditions are an optional part of an automation rule and can be used to prevent an action from happening when triggered. Conditions look very similar to triggers but are very different. A trigger will look at events happening in the system while a condition only looks at how the system looks right now. A trigger can observe that a switch is being turned on. A condition can only see if a switch is currently on or off.

The available conditions for an automation are the same as for the script syntax so see that page for a full list of available conditions.

Example of using condition:

- alias: 'Enciende Despacho'
    platform: state
    entity_id: sensor.mini_despacho
    to: 'on'
    condition: or
      - 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