States: an entity in a zone is NOT not_home?

I want certain things to trigger only for the 1st one home. This works if the other person is “away” but not if they are in a defined zone.

  - if:
      - condition: or
        conditions:
          - condition: state
            entity_id: person.jim
            state: not_home
          - condition: state
            entity_id: person.rafi
            state: not_home
    then:
      - service: media_player.turn_on
        data: {}
        target:
          device_id: xxx
      - service: media_player.select_source
        data:
          source: YouTube
        target:
          device_id: xxx
      - service: media_player.play_media
        target:
          entity_id: media_player.home_group
        data_template:
          media_content_id: media-source://tts/google_translate?message="{{message}}"
          media_content_type: provider
        enabled: true
    else: []

That’s because if they are in a defined zone they will not be ‘not_home’

You could replace the if: with the following:

   - if:
      - condition: state
        entity_id: zone.home
        state: '1'

you could use the “not” condition.

I think this logic should work:

  - if:
      - condition: or
        conditions:
          - not:
              - condition: state
                entity_id: person.jim
                state: home
          - not:
              - condition: state
                entity_id: person.rafi
                state: home

Thanks I’ll give these a shot and report back

I must not have the conditions nested correctly…HA inserted these null statements

 - if:
      - condition: or
        conditions:
          - not: null
          - condition: state
            entity_id: person.jim
            state: home
          - not: null
          - condition: state
            entity_id: person.rafi
            state: home

yours:

- if:
      - condition: or
        conditions:
          - not: null
          - condition: state
            entity_id: person.jim
            state: home
          - not: null
          - condition: state
            entity_id: person.rafi
            state: home

mine:

  - if:
      - condition: or
        conditions:
          - not:
              - condition: state
                entity_id: person.jim
                state: home
          - not:
              - condition: state
                entity_id: person.rafi
                state: home
1 Like