Conditions are checked after an automation has executed its trigger (and it changed from false
to true
).
A State Condition compares an entity’s state
value to a reference value. It makes a true
/false
decision. When does it make this decision? After the automation’s trigger has executed. Why? Because a steady-state value isn’t an event (unless time is involved) and triggers are event-based (i.e. they monitor and detect changes).
A State Trigger detects when an entity’s state
value changes to a new value. It optionally compares the new value to a reference value (to
, from
) and use a time constraint (for
).
A Time Condition compares the current time to a reference time (or time range). It makes a true
/false
decision after the automation’s trigger.
A Time Trigger detects when the current time changes and matches a reference time (or times).
A script is functionally equivalent to an automation without a trigger. A script does nothing until you execute it with a service call.
EDIT
I believe Didgeridrew’s example fulfills your described requirements. It turns on p2 but only if p1 is on and the time is within a desired range. It achieves this efficiently, using a combination of triggers and conditions.
You claimed it “doesn’t work” but, respectfully, I suspect you don’t understand how it works. You said “I can’t make the state changes during that hours”. P1 isn’t obligated to make a state-change during the time range. If p1 is on before the time range, the moment the current time enters the time range, the automation will trigger, confirm p1 is on and turn on p2. That’s what you had requested; turn on p2 during the time range but only if p1 is on.