Template Binary Sensor triggers to 'on' when HA starts without ever actually reading 'off'? Is this a bug?

So I set up some a Template Binary Sensor to check if the outside temperature is less than 71F:

configuration.yaml:

# binary sensor of outside vs 71
binary_sensor:
  - platform: template
    sensors:
      hot_outside:
        friendly_name: "Outside is warmer than 71"
        device_class: heat
        value_template: "{{ states('sensor.outside_window_temperature') | int > 71 }}"

And I use an Automation to notify me when it is hot out (so we can turn off the window fan and close the windows):

automations.yaml:

- id: notify_hot_out
  alias: Notify when it is warmer outside
  trigger:
  - platform: state
    entity_id: binary_sensor.hot_outside
    from: 'off'
    to: 'on'
    for:
      minutes: 1
  condition:
  - condition: template
    value_template: > # don't trigger if it was triggered within the last 4 hours
      {%- if states.automation.notify_when_it_is_warmer_outside.attributes.last_triggered -%}
        {{(as_timestamp(now()) - as_timestamp(states.automation.notify_when_it_is_warmer_outside.attributes.last_triggered)) > 14400}}
      {%- else -%}
        true
      {%- endif -%}
  action:
  - service: notify.dadsms
    data:
      title: Hot outside
      message: It is now {{states.sensor.outside_window_temperature.state}} °F outside,
        time to close the windows and turn off the fan

And this tries to trigger every time I reboot Home Assistant. Looking at the History graph shows a blip of “Normal” for less than a minute on every reboot, and the log records an “Outside is warmer than 71 detected heat” without a preceding “Outside is warmer than 71 cleared (no heat detected)”(see 2:03PM in these shots).

So the Automation tries to trigger since the sensor went from ‘off’ to ‘on’ even though there was never an ‘off’ recording logged? Anyone understand why this happens or if it should be reported as a bug?

For now, the solution I’m trying is using an Uptime sensor as described here.

Any cleaner methods?

You have no platform specified.

binary_sensor:
      hot_outside:
        friendly_name: "Outside is warmer than 71"
        device_class: heat
        value_template: "{{ states('sensor.outside_window_temperature') | int > 71 }}"

Try

binary_sensor:
  platform: template
  sensors:
    hot_outside:
      friendly_name: "Outside is warmer than 71"
      device_class: heat
      value_template: "{{ states('sensor.outside_window_temperature') | int > 71 }}"

Sorry, yes that was further up in my configuration.yaml (with the first binary sensor) and I failed to copy the full section, edited post to reflect that. Thanks!

What happens if you add an entity to the sensor so that HA knows what to monitor?

binary_sensor:
  platform: template
  sensors:
    hot_outside:
      friendly_name: "Outside is warmer than 71"
      entity_id: sensor.outside_window_temperature
      device_class: heat
      value_template: "{{ states('sensor.outside_window_temperature') | int > 71 }}"

Just tested: same result. Still shows an off/normal state blip on reboot.

What reports to sensor.outside_window_temperature? Could it be that that number is actually lower than 71 when Home Assistant starts up? What does your binary_sensor.template do if sensor.outside_window_temperature is “unavailable” (as it may be when the component that populates it starts up as well).