Hello, I was modifying one of my automation which is sending the notification about to turn on vacuum based on states of two entities and time of a day.
First part is checking if today is more than 3 days (written by start vacuum automation into the helper) the vacuum was running OR if the reminder is on AND if it is specific time of a day.
template is here: {{ (now().strftime('%Y-%m-%d') > states('input_datetime.stetka_uklid') or states('input_boolean.stetka_reminder') == "on") and now() == today_at("16:15") }}
That part with OR works fine but the other part seems always false → now() == today_at("16:15"). It is really confusing me. I know now() itself is super detailed with all those milliseconds and whatever but there has to be a match at some point with today_at("whatever:time:chosen")
I spent some time trying to find “the truth” in developer tools but obviously I would need more luck to match and get a True . Simple >= instead of == works fine and solved my problem, maybe even better if for some reason HA is down in that specific time. But I would be happier if I knew why there is no match when == is used. Anybody has a clue?
I’d retailor your automation to use a time trigger.
trigger:
- id: datetime
platform: time
at: input_datetime.stetka_uklid
- id: at
platform: time
at: "06:15:00"
condition:
- condition: template
value_template: "{{ trigger.id == 'at' and is_state('input_boolean.stetka_reminder', 'on') or trigger.id == 'datetime' }}"
action:
...
Much more predictable.
if you want to condense everything more…
trigger:
- platform: time
at:
- input_datetime.stetka_uklid
- "06:15:00"
condition:
- condition: template
value_template: "{% set v = trigger.now().strftime('%H%M') == '06:15' %}{{ v and is_state('input_boolean.stetka_reminder', 'on') or not v }}"
action:
...
Interesting, never thought time integration would be good for anything. I would probably go for @Troon suggestion as my input_datetime is date only and I am lazy to redo it .
But @petro thank you for your part, there is an information for me with set which I thought it cannot be used in template .