How often will this template binary sensor refresh?
wondering if I should add a trigger or if anything now() based will automatically refresh every x seconds? or once every day at midnight since it has now().day as the smallest interval?
Thank you, thatâs what I thought. However the sensor history was supposed to be âonâ since October 1st but for some reason only started showing âonâ when I restarted HA yesterday. Odd.
Hmm. Maybe it is once a day if using .day. I know bdraco did a lot of optimisation of this.
You could usse a triggered template sensor. They are restored at start up (no actual need to trigger at start).
- trigger: time
at: '0:00' # trigger once a day at midnight
binary_sensor:
- name: "SEASON heating"
unique_id: season_heating
state: "{{ not ((5,1) < (now().month, now().day) < (10,1)) }}"
Though this too will be unknown until the first time 0:00 occurs. Then it should be restored after a restart at any time.
You can update it manually using Developer Tools â Actions, homeassistant.update_entity.
thanks! just weird that it would have never triggered in almost 2 months.
guess it doesnât hurt to add the trigger.
I have a number of these âseasonsâ, will add the trigger for all
but I had to change the syntax to make it work, not sure if yours/mine is accurate or not?
So if I understand correctly, both triggers/syntax (yours/mine) should run fine, I can simply ignore the VScode helper messages. (or open issue/fix myself)
If youâre bothered about updates (and no need to be, youâve used up orders of magnitude more time on this topic than your HA will have done recalculating), you can install the time-date integration and do something like this with no need for triggers: