Prevent Template Binary Sensor changing on reboot

I’m using a Template Binary Sensor to determine if my home is occupied or not:

- platform: template
      friendly_name: "Home Occupied"
        minutes: 5
      value_template: >-
        {{ is_state('group.all_devices', 'home')
            or is_state('binary_sensor.alecs_flat_away', 'off') # provided by Nest
            or is_state('light.entryway_lightstrip', 'on') }}

I have automations that use this sensor e.g.

- id: arriving_home
  alias: 'Arriving home'
    platform: state
    entity_id: binary_sensor.home_occupied
    from: 'off'
    to: 'on'
    # etc.

The above automation triggers on every restart of Home Assistant which I’m trying to prevent.

I’v tried using delay_off to prevent it switching to off during restart, that doesn’t seem to work though. There doesn’t seem to be an initial_state for Template Binary Sensors either.

I could add a condition in my automation to check my device is not at home, but that kind of defeats the point of my home_occupied sensor.

Any ideas?

I solved this with help from this post. First I enabled the Uptime Sensor which gave me time since boot in minutes:

- platform: uptime
  name: "HA runtime in minutes"
  unit_of_measurement: minutes

Then used it as a condition in my “Arriving home” automation:

- condition: numeric_state
  entity_id: sensor.ha_runtime_in_minutes
  above: 5