So if you have a sequence that goes 0,1,2,3, is there code somewhere in the system that updates when the sequence is at 0?
Also the doc you posted has a few interesting notes on changing state.
In the below example, re-renders are limited to once per minute because we iterate over all available entities:
template:
- binary_sensor:
- name: "Has Unavailable States"
state: "{{ states | selectattr('state', 'in', ['unavailable', 'unknown', 'none']) | list | count }}"
In the below example, re-renders are limited to once per second because we iterate over all entities in a single domain (sensor):
template:
- binary_sensor:
- name: "Has Unavailable States"
state: "{{ states.sensor | selectattr('state', 'in', ['unavailable', 'unknown', 'none']) | list | count }}"
Those could be interesting directions to explore.
It seems like some people claim they get this sort of thing working with Trigger-based Template sensors with a Time Pattern Trigger so I will probably try that next as that is not beholden to the rate limiting.
The template-editor is really useful, thanks for all the help.