Hi,
is there a way to express a “for less than” X minutes/seconds in a state trigger or condition?
For example, I want to trigger an automation only if a switch has been off for less than, say, 5 seconds.
How would you do that?
Thanks
gl
Hi,
is there a way to express a “for less than” X minutes/seconds in a state trigger or condition?
For example, I want to trigger an automation only if a switch has been off for less than, say, 5 seconds.
How would you do that?
Thanks
gl
I found a hint for a possible solution here:
isn’t there a language construct to express this?
I am also looking for a solution for this. Did you ever figure it out?
Maybe i don’t understand what you mean, but which value do you expect for ‘less than X’?
automation:
trigger:
platform: state
entity_id: switch.my_switch
state: 'off'
for:
seconds: X-1
that’s less than X.
Yeah, it’s something like:
- alias: Movement detected right after light switched off
trigger:
- platform: state
entity_id: binary_sensor.pir
from: 'off'
to: 'on'
condition:
condition: template
value_template: '{{(as_timestamp(now()) - as_timestamp(states.switch.my_light.last_changed) < 2)}}'
action:
- service: homeassistant.turn_on
entity_id: switch.my_light
- service: homeassistant.turn_on
entity_id: input_boolean.keep_my_light_on