Hi,
I’m beginning with HA and I’m a but surprised be confusing behavior of template binary sensors. I’m not sure if this is intentional or if there is any way around.
If I have ordinary binary_sensor (not template), for example something like this:
binary_sensor:
- platform: ping
host: 192.168.0.2
… it keeps its state during homeassistant startup and reload it right after HA is started. This is what I’d expect.
However, if I have basically any template binary sensor, no matter value of its template:
binary_sensor:
- platform: template
sensors:
test_1:
value_template: "{{ 1 }}"
test_2:
value_template: "{{ states('sensor.uptime_sec') < 60 }}"
test_3:
value_template: "{{ is_state('foo.bar', "on") }}"
They are all set to “off” state during the first seconds of HA startup, and restored to proper state ~30 seconds afterwards (when HA finishes it startup).
Is this proper behavior, or I’m doing anything wrong? Is there any way around?
And for example - if I have automation based on state of these sensors, I will have to always add some delay condition to avoid unwanted actions during HA startup. But only for template binary sensors, not for ordinary binary sensors. Is this true?