Conditions: Gating an Automation's Actions
Conditions are the optional gatekeepers of an automation. They sit between the
trigger and the actions, deciding whether the run is allowed to continue. Once
something fires the automation, WoowTech checks every condition you've listed;
the actions run only if all of them come back true. The instant one returns
false, the run halts and nothing further happens.
How Conditions Differ from Triggers
At a glance triggers and conditions look alike, but they answer different questions. A trigger watches for something happening and kicks the automation off. A condition, by contrast, only inspects the present state of things once the automation is already underway.
That gap matters when timing is tight. Picture a switch that's flicked on and then immediately off again. The "turned on" moment is enough to fire a trigger — yet by the time the conditions are evaluated a fraction of a second later, the switch may already read off. That mismatch is what's known as a race condition.
Which Conditions Are Available
Automations draw from the same condition catalog that scripts use. The scripts conditions reference lists every one of them.
Examples
Combining Conditions with OR Logic
Here a hallway light is switched on by motion, but only when it's genuinely dark — either the sun has dropped low enough, or the brightness sensor reads dim.
automation:
- alias: "Light the hallway on motion"
triggers:
- trigger: state
entity_id: binary_sensor.hallway_motion
to: "on"
conditions:
- or:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
below: 6
- condition: numeric_state
entity_id: sensor.hallway_brightness
below: 15
actions:
- action: scene.turn_on
target:
entity_id: scene.hallway_evening
Supplying a Single Template Condition
The conditions key will also accept one inline template instead of a list. The
automation below behaves like the previous one but expresses its gate as a
single Jinja expression.
automation:
- alias: "Light the hallway on motion"
triggers:
- trigger: state
entity_id: binary_sensor.hallway_motion
to: "on"
conditions: "{{ state_attr('sun.sun', 'elevation') < 6 }}"
actions:
- action: scene.turn_on
target:
entity_id: scene.hallway_evening
Conditions: Gating an Automation's Actions
Conditions are the optional gatekeepers of an automation. They sit between the
trigger and the actions, deciding whether the run is allowed to continue. Once
something fires the automation, WoowTech checks every condition you've listed;
the actions run only if all of them come back true. The instant one returns
false, the run halts and nothing further happens.
How Conditions Differ from Triggers
At a glance triggers and conditions look alike, but they answer different questions. A trigger watches for something happening and kicks the automation off. A condition, by contrast, only inspects the present state of things once the automation is already underway.
That gap matters when timing is tight. Picture a switch that's flicked on and then immediately off again. The "turned on" moment is enough to fire a trigger — yet by the time the conditions are evaluated a fraction of a second later, the switch may already read off. That mismatch is what's known as a race condition.
Which Conditions Are Available
Automations draw from the same condition catalog that scripts use. The scripts conditions reference lists every one of them.
Examples
Combining Conditions with OR Logic
Here a hallway light is switched on by motion, but only when it's genuinely dark — either the sun has dropped low enough, or the brightness sensor reads dim.
automation:
- alias: "Light the hallway on motion"
triggers:
- trigger: state
entity_id: binary_sensor.hallway_motion
to: "on"
conditions:
- or:
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
below: 6
- condition: numeric_state
entity_id: sensor.hallway_brightness
below: 15
actions:
- action: scene.turn_on
target:
entity_id: scene.hallway_evening
Supplying a Single Template Condition
The conditions key will also accept one inline template instead of a list. The
automation below behaves like the previous one but expresses its gate as a
single Jinja expression.
automation:
- alias: "Light the hallway on motion"
triggers:
- trigger: state
entity_id: binary_sensor.hallway_motion
to: "on"
conditions: "{{ state_attr('sun.sun', 'elevation') < 6 }}"
actions:
- action: scene.turn_on
target:
entity_id: scene.hallway_evening
Start writing here...