Well,
I changed the test automation to clean in up, take less space, sort the quotes etc. and toggle every 2 minutes, ended up with : -
automation:
- alias: Now Test Automation
trigger:
- platform: template
value_template: "{{ now().strftime('%F') == (now().strftime('%Y') | int ) ~ '-03-12' and now().strftime('%R') [4:5] | int in [0,2,4,6,8] }}"
action:
- service: input_boolean.toggle
entity_id: input_boolean.ib_global_test
Without any further intervention from me this now toggles the boolean every two minutes - This Should Not Work ! But it does !
Admittedly I just hate this, I wouldnât rely on it cos it may just be that someone will find the error and correct it so it wonât work next week !
Interestingly my processor usage and average load has not budged so Itâs not even consuming much resources. WEIRD !
I just looked at it, saw it was trying to give a True/False but had evaluated the necessary bit, didnât see the point in the rest and discontinued reading.
My Bad - Thanks for pointing it out
All four templates have no identifiable entities and all rely on the now() function.
Each automationâs action simply toggled an input_boolean.
Only the automation using the first template worked (i.e. it toggled the input_boolean on even minutes).
Itâs an interesting result and, on the face of it, challenges the documentationâs broad assertion that the template must contain an identifiable entity and that now() cannot be used as a trigger. However, itâs a very subtle exception to the rule because 3 out of the 4 variations failed to work.
The second template relies on now() but doesnât trigger the automation.
The third template does some simple arithmetic but doesnât trigger the automation.
The fourth template adds string concatenation but also fails to trigger the automation.
The first one is almost the same as the second one but performs integer division and that seems to make a difference. In the case of the first template, Home Assistant appears to have assigned a listener to the automationâs trigger.
looking at your templates, they ALL seem to ALWAYS evaluate to True apart from the first
And @daveyrb 's uses the time to evaluate, not just the minute, mine takes the time and strips to the last âunit valueâ of minute as well (so mines well less efficient aswell).
Only the first is capable of returning false but the template has to be evaluated in order to determine that. Whatâs causing the template to be evaluated? It would be a listener assigned to monitor it. That listener appears to be evaluating it when now().minute changes value. So why arenât the other three templates being handled the same way? I donât know the answer to that.
itâs does not use whatâs already there (days) and therefore is slower/worse - thatâs true.
but I think there is nothing wrong in not returning False - the docs say only about True and anything else (including None which is most likely what it gets) is interpreted as ânot Trueâ i.e âFalseâ.
Seems that long nights are not so good
Tried example by Taras123 in post 31- all works but how to reset the binary sensor after expire- 0:00 next day? Now it remains active despite date change.
TIA and best, JR
And another q: how to find out e.g. 3rd Sunday in May in template?
Sorry⌠as I said looooong night coding
This was Taras (123) post #15âŚ
Can not see why binary_sensor did not reset at midnight (and the group also remained true) so it reminded me the next day too (wrong date) - with developer tools all works OK⌠go figure⌠will try again today.
And is this very primitive way to find out e.g. second Sunday in November like this:
{{ now().month == 11 and now().isoweekday() == 7 and now().day > 7 and now().day < 15 }}
Sorry for misinformation- next time will rest before coding again
Best, JR
Did you configure the Time & Date integration? The binary_sensors are updated when sensor.date changes state which is once per day at the start of the day. You must define sensor.date using the Time & Date integration.
That is really embarrassing
How could I stupidly run HA for 3 years without it and all was neat
Somehow I assumed it is included by default- so RTFM more frequently (note to myself)!
Thank You- saved my weekend âŚ
Best, JR