Hi all,
I am trying to setup an automation that will only run if my doorbell hasn’t been pressed for at least 60 seconds.
I have started by using the IF-ELSE action with a template:
if:
- condition: template
value_template: >-
{%- set ts_event = as_timestamp(states.binary_sensor.front_door_bell.last_changed)|round(0) %}
{%- set ts_now = as_timestamp(now())|round(0) %}
{%- set ts_delta = (ts_now - ts_event) %}
{{ ts_delta > 60 }}
then: []
The code is borrowed from: Difference in seconds between input_datetime and now() and if I put it in the dev tools it runs and prints out True
but in the automation will not pass regardless of the time (even if I change >
for <
)
I’ve been searching on using if with templates, but all I have found is about using IF-ELSE inside templates.
I have obviously got something wrong but I have been unable to search and figure out what it is, and have just confused myself further