Status-toggle automation for person's presence

Hi there! I am trying to make an automation to control the home status of three people, including a fictitious ‘guest’ user, via a toggle. This way I can easily change a wrong status of another person or register a guest (and disable all ‘burglar’-style automations). At this point the automation works for person C, but not for the other persons, even though I have defined device_tracker.guest_input_boolean for the guest and likewise for the other two users at People-> Track Device. May I ask you to take a quick look because it feels like I’m overlooking something simple.

alias: "Presence detection 1/2"
description: "Toggle voor person presence."
trigger:
  - platform: state
    entity_id:
      - input_boolean.cgebruiker_presence
      - input_boolean.mgebruiker_presence
      - input_boolean.guest_presence
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.cgebruiker_presence
            state: "on"
        sequence:
          - service: device_tracker.see
            data:
              dev_id: cgebruiker_input_boolean
              location_name: 'home'
            data_template:
              dev_id: cgebruiker_input_boolean
              location_name: 'home'
      - conditions:
          - condition: state
            entity_id: input_boolean.mgebruiker_presence
            state: "on"
        sequence:
          - service: device_tracker.see
            data:
              dev_id: mgebruiker_input_boolean
              location_name: 'home'
            data_template:
              dev_id: mgebruiker_input_boolean
              location_name: 'home'
      - conditions:
          - condition: state
            entity_id: input_boolean.guest_presence
            state: "on"
        sequence:
          - service: device_tracker.see
            data:
              dev_id: guest_input_boolean
              location_name: 'home'
            data_template:
              dev_id: guest_input_boolean
              location_name: 'home'
#Zelfde als hierboven maar dan voor 'not_home'
      - conditions:
          - condition: state
            entity_id: input_boolean.cgebruiker_presence
            state: "off"
        sequence:
          - service: device_tracker.see
            data:
              dev_id: cgebruiker_input_boolean
              location_name: 'not_home'
            data_template:
              dev_id: cgebruiker_input_boolean
              location_name: 'not_home'
      - conditions:
          - condition: state
            entity_id: input_boolean.mgebruiker_presence
            state: "off"
        sequence:
          - service: device_tracker.see
            data:
              dev_id: mgebruiker_input_boolean
              location_name: 'not_home'
            data_template:
              dev_id: mgebruiker_input_boolean
              location_name: 'not_home'
      - conditions:
          - condition: state
            entity_id: input_boolean.guest_presence
            state: "off"
        sequence:
          - service: device_tracker.see
            data:
              dev_id: guest_input_boolean
              location_name: 'not_home'
            data_template:
              dev_id: guest_input_boolean
              location_name: 'not_home'

Here’s an animation of how it works:
output-onlinegiftools

Does it matter that the two other perso entities don’t have a user_id in their attributes? By the way, I added all the persons through the GUI, so my YAML is just:

person:

If there’s anyone with a better solution than the above, I have no problem in trying that and starting fresh :slight_smile: .

Hey. I will share a solution I did via pyscript. Steps:

  1. create a new person (I called them Guest), can be done via UI
  2. create a new helper Toggle which translates into e.g. an input_boolean, so e.g. input_boolean.guest_present, can be done via UI
  3. create a new pyscript with the following content:
@service
def set_state(name, value):
    """yaml
name: Set state
description: Sets entity to the given state
fields:
  name:
     description: full name of the entity
     example: person.guest
     required: true
  value:
     description: value to be set
     example: not_home
     required: true
    """
    state.set(name, value)
  1. create a new automation based on the change of the toggle:
alias: Change guest presense
description: 'Changes presence of Guest based on toggle'
trigger:
  - platform: state
    entity_id:
      - input_boolean.guest_present
  - platform: homeassistant  # is here to set the value on startup so it's not "unknown"
    event: start
action:
  - if:
      - condition: state
        entity_id: input_boolean.guest_present
        state: 'on'
    then:
      - service: pyscript.set_state
        data:
          name: person.guest
          value: home
    else:
      - service: pyscript.set_state
        data:
          name: person.guest
          value: not_home
mode: single

Then I added the dead-simple entities toggle switch on my dashboard:

type: entities
entities:
  - input_boolean.guests_presents

and voila:
image
image

I am really happy with this solution!