I’ve configured automations to automatically shut the window blinds in the south direction at sunshine. I’ve got a LUX sensor on that wall and have configured automations like this:
alias: Sonnenschutz automatisch aktiv
description: Aktiviert den Sonnenschutz, wenn 20 Minuten oberhalb der Lichtstärke
trigger:
- platform: numeric_state
entity_id: sensor.hmip_slo_000d5d89b9f87c_durchschnittliche_beleuchtungsstarke
for:
hours: 0
minutes: 20
seconds: 0
above: 55000
condition:
- condition: state
entity_id: input_boolean.sonnenschutz_status
state: "off"
action:
- service: script.rl_vorne_sun
data: {}
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.sonnenschutz_status
- service: notify.all_ios_devices
data:
message: Der Sonnenschutz wurde automatisch deaktiviert
title: Sonnenschutz
mode: single
So, this automation is supposed to trigger when the lightning value exceeds 55000 for 20 minutes with the condition that the “input_boolean.sonnenschutz_status” is off.
I have a second condition which triggers when the lighning intensity is below 50000 for 30 minutes. Today it was in this state for an hour, the condition of “input_boolean.sonnenschutz_status” was fulfilled. But nothing happened.
I’ve temporarily rewritten these automations to trigger time based every 20 minutes, and they work - I’ve put the lighning value in the conditions instead.
But I really want to know why the trigger condition above does not work. Any ideas in the community?
The trigger only happens when the condition is true for exactly the duration specified, and without interruption. If at that specific moment the condition below fails, the automation won’t run again until the light value falls falls below 55000 and and then goes above that value for the exact, uninterrupted length of 20 mins again. So being in the state for over an hour is indeed not triggering, because the trigger moment has passed 40 mins ago.
So the input boolean turning off should also be a trigger, and the 20 mins sun should also be a condition.
when I created the second automation (lightning level must below 50000 for 30 Mins), the level was above 50000. The binary condition is just a helper to aviod repeated activations when the state of the sun protection is not which should cause the change.
So, at the time of automation creation:
Level was above 50000
“input_boolean.sonnenschutz_status” was “on”
The automation:
alias: Sonnenschutz automatisch raus
description: Deaktiviert den Sonnenschutz, wenn 30 Minuten unterhalb der Lichtstärke
trigger:
- platform: numeric_state
entity_id: sensor.hmip_slo_000d5d89b9f87c_durchschnittliche_beleuchtungsstarke
for:
hours: 0
minutes: 30
seconds: 0
below: 50000
condition:
- condition: state
entity_id: input_boolean.sonnenschutz_status
state: "on"
action:
- service: script.rl_vorne_sun
data: {}
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.sonnenschutz_status
- service: notify.all_ios_devices
data:
message: Der Sonnenschutz wurde automatisch deaktiviert
title: Sonnenschutz
mode: single
With the lightning level well above 50000 at the time of automation creation and “input_boolean.sonnenschutz_status” all the time “on”, I’d expect the automation to trigger when the level is 30 minutes below 50000.
From the curve of the sensor I saw that the value was constantly falling in the evening, being 60 minutes below 50000 - and no trigger happened. That’s what confused me.
I never saw the automation being triggered in debug, so the binary sensor status was never checked because the trigger never triggered. That’s what’s confusing me …
Good point, I did that. The sensor is a radio link sensor (Homematic IP), so it might miss an update.
How will HA behave if it shortly drops to unavailable? Will this reset the timer and the time where it needs to be above 55000 will start from scratch?
It will simply not validate your trigger => no triggering… And no, the automation will not start again, as the treshhold (your value changes under 50000) is already passed. There is no re-check or something like that.
I’ll try to explain it:
Sensor goes from 50000 to 49999
Automation triggers
The automation waits for 30 minutes
Condition is checked, if true, it goes forward, if not, the automation stops.
Now with a disturbance:
Sensor goes from 50000 to 49999
Automation triggers
The automation waits for 30 minutes
Sensor goes unavailable
The internal “timer” is stopped and deleted
The automation stops and waits for the next time to be triggered
Sensor comes back on with a value of 49999 (<= and this is why it won’t trigger again, the value doesn’t pass the treshhoild again!)
Hope that’s understandable. What you’re experiencing is the difference between a trigger and a condition.
Trigger
Fires, when something changes it’s value (from x to y)
Condition
Checks a value in exactly that moment it is called in the code for a condition (is value Y at that moment)