I’m really really new to Home Assistant and I’ve been having a lot of fun! I have googled this but I got confused… which isn’t a good sign. But I have been trying to not need to make a new topic.
Basically I’ve got a presence sensor in the kitchen. And in the day if you close the blind it turns on the light. But right now if you close it and you’re already in the kitchen. Well it doesn’t happen again until you leave the kitchen and come back.
I made this in the UI not Yaml but here’s the yaml… I really feel I’m going to need the solution explained as simply as possible.
I thought about having the light just turn on if you close the blind (like as a second trigger) to sort of get around it but I’d like something that would work with any presense sensor.
alias: Kitchen on day
description: ""
triggers:
- trigger: state
entity_id:
- binary_sensor.presence_sensor_2326_occupancy
from:
- "off"
to:
- "on"
conditions:
- condition: device
device_id: 98b106502890ec94936d1df541d86174
domain: cover
entity_id: 86906490d143a9d48983dc9ce2e2f8f2
type: is_tilt_position
below: 90
- condition: state
entity_id: input_boolean.motion
state:
- "on"
- condition: state
entity_id: input_boolean.temp_motion
state:
- "on"
- condition: sun
after: sunrise
after_offset: "-00:20:00"
actions:
- action: scene.turn_on
metadata: {}
target:
entity_id: scene.kitchen_energise
data: {}
mode: single
Are an event happening.
For example you turn a switch on or off.
They are only relevant at the moment in time when the thing happened.
And they can only trigger on one event (one thing changing).
Conditions
Are a way to check the state of something: is a switch on or off.
Conditions don’t “notice” when something changes, so if you had an automation with only conditions (no triggers) it would never do anything because a condition changing doesn’t trigger the automation.
Simple Automations
For very simple automations (meaning only one trigger) you typically don’t need any conditions:
If someone turns on a light switch.
Then turn on the light.
More Complex Automations
Say I have two switches A and B and I only want a light to come on when both switches are turned on.
I would typically need two triggers:
If A “becomes” on.
If B “becomes” on.
And I would need two conditions:
If A “is” on.
If B “is” on.
If I had no conditions if either switch “became” on the light would turn on - the trigger doesn’t have a mechanism to check the state of the other switch.
If I only had a trigger on switch B then the automation would work as long as I always turned on switch A first. - since when the trigger fires for B the condition would check to see if A was also on.
So the general pattern is, if you want to check if X things are true you need X triggers and the same (or very similar) checks need to be expressed as conditions (X conditions).
Summary
Imagine you have two workers:
A really active dumb worker that notices when anything changes (but can only do one simple check) - triggers.
A worker that can do complex stuff, but falls asleep whenever it stops doing something - conditions.
For simple automations you don’t need the smart worker - the dumb one can handle it.
For more complex automations you need both - the dumb worker will wake up the smart one.