Template binary sensor always set to "off" during HA startup

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?

I can confirm the same behavior on my system.

Until Home Assistant computes the Template Binary Sensor’s state, its state prior to computation is off. This only happens on startup and not after Reload Template Entities.

For example, I created your first Template Binary Sensor at approximately 4:05 PM , executed Reload Template Entities, and it set itself to on (as expected). It remained on for several minutes and then, seconds after 4:11 PM, I restarted Home Assistant. After startup, the history shows the Template Binary Sensor was off before 4:11 PM (even though it was actually on).