Device.tracker & binary_sensor state change during HA restart?

I have a “Welcome Home” automation triggered by

    trigger:
      platform: template
      value_template: >
        {{ is_state('device_tracker.wife','home') and
          (now() - states.device_tracker.wife.last_changed).total_seconds() < 300 and
          (now() - states.binary_sensor.door_sensor_opened.last_changed).total_seconds() < 300 }}

This checks if the wife just got home (phone connects to router) and has to be inside before the automation triggers.

This works okay, but since maybe 0.100 the automation now also triggers on HA restart. I see in the logbook that the device tracker goes to Away during the restart and I assume the door sensor state changes during that time as as well.

I couldn’t find anything in the release notes about this changed behavior, but maybe I wasn’t looking at the right keywords. Anyone knows if this is intended or not? I guess I could check for recent HA restarts as well

I’m noticing this as well. Any fix?

I added a check for uptime to get around this

    trigger:
      platform: template
      value_template: >
        {{ is_state('device_tracker.wife','home') and
          (now() - states.device_tracker.wife.last_changed).total_seconds() < 300 and
          (now() - states.binary_sensor.door_sensor_opened.last_changed).total_seconds() < 300 and
          ( states.sensor.uptime.state | float * 24 * 3600 ) > 300}}

You get uptime by adding

sensor:
  - platform: uptime
3 Likes