Why am I getting an error for this automation condition for template sensor based on person?

Whenever I reload the template entities I get this error:

Logger: homeassistant.components.automation
Source: components/automation/__init__.py:740
Integration: Automation (documentation, issues)
* Error evaluating condition in 'Turn on lights when someone arrives': In 'condition' (item 2 of 2): In 'state': In 'state' condition: unknown entity sensor.people_already_home

These are the automations:

automation:
  - id: turn_on_lights_when_someone_arrives
    alias: 'Turn on lights when someone arrives'
    trigger:
      - platform: state
        entity_id: sensor.people_just_arrived
        from: ''
    condition:
        - condition: state
          entity_id: 'input_boolean.guest_mode'
          state: 'off'
        - condition: state
          entity_id: 'sensor.people_already_home'
          state: ''
    action:
      - service: light.turn_on
        entity_id: light.main_room
  #
  - id: turn_off_all_lights_when_everyone_leaves
    alias: 'Turn off all lights when everyone leaves'
    trigger:
      - platform: state
        entity_id: sensor.people_just_arrived
        to: ''
        for:
          minutes: 10
      - platform: state
        entity_id: sensor.people_already_home
        to: ''
        for:
          minutes: 10
    condition:
      condition: and
      conditions:
        - condition: state
          entity_id: 'input_boolean.guest_mode'
          state: 'off'
        - condition: state
          entity_id: sensor.people_just_arrived
          state: ''
        - condition: state
          entity_id: sensor.people_already_home
          state: ''
    action:
      - service: light.turn_off
        entity_id: all

These are the template sensors:

sensor:
  - platform: template
    sensors:
      people_just_arrived:
        friendly_name: 'People just arrived'
        value_template: >-
          {% for person in states.person 
              if  person.state_with_unit == 'home' 
              and (utcnow()-timedelta(minutes=10)) <= person.last_changed -%}
            
            {%- if loop.first %}{% elif loop.last %} and {% else %}, {% endif -%}
            {{ person.name -}}
            {# ({{ utcnow() - person.last_changed }})#}
            {%- if loop.last -%}
              {% if loop.first %} is {% else %} are {% endif -%}
              at {{person.state_with_unit}}.
            {%- endif -%}

          {%- endfor %}
      #
      people_already_home:
        friendly_name: 'People already home'
        value_template: >-
          {% for person in states.person 
              if  person.state_with_unit == 'home' 
              and (utcnow()-timedelta(minutes=10)) > person.last_changed -%}
            
            {%- if loop.first %}{% elif loop.last %} and {% else %}, {% endif -%}
            {{ person.name -}}
            {# ({{ utcnow() - person.last_changed }})#}
            {%- if loop.last -%}
              {% if loop.first %} is {% else %} are {% endif -%}
              at {{person.state_with_unit}}.
            {%- endif -%}
          
          {%- endfor %}
      #

I assume I’m getting that error because I don’t have “availability_template” for sensor.people_already_home, but it only uses the person domain so I’m not sure what it should be.

What’s extra strange is that the “Turn off all lights when everyone leaves” automation isn’t mentioned in the logs, so that one must be fine for some reason.

Can anyone explain what’s going on here? Do I need to figure out how to set unavailability for the sensor that only uses the person domain? Or if that’s the wrong question I’d appreciate being pointed in the right direction.