Notify me if someone is home

Hi all,

i wrote an automation if somebody comes home that the light is switching on an a push notification should be send out who is home.
So far the automation works nice but i have the problem with the push-notification:

service: notify.family_push
data:
  message: >-
    {{ 'NameA' if trigger.to_state.entity_id == 'device_tracker.xxxNameA' else
    'NameB' }} is {{ trigger.to_state.state }}

When device_tracker.xxxNameA went home i alway get as pushnofication: NameB is home. So never getting NameA is home

Do you have a hint what i am doing wrong?
Thanks

post the full automation

alias: When I arrive
description: ''
trigger:
  - platform: state
    entity_id: group.devices_family
    from: not_home
    to: home
condition: []
action:
  - service: notify.family_push
    data:
      message: >-
        {{ 'AA' if trigger.to_state.entity_id == 'device_tracker.AA'
        else 'BB' }} is {{ trigger.to_state.state }}
  - condition: numeric_state
    entity_id: sensor.XXXX_average_illumination
    below: '600'
  - scene: scene.abendstimmung
mode: single

It’s the group that’s triggering, not the individual person. If you list everyone separately in the trigger it should work.

Hi,
thanks for the hint but i still didn´t get it running at all. Do you have a code example?
I tried the following which did also not work

alias: When I arrive
description: ''
trigger:
  - platform: state
    entity_id:
      - device_tracker.A
      - device_tracker.B
    to: home
condition: []
action:
  - service: notify.family_push
    data:
      message: >-
        {{ 'NameA' if trigger.to_state.entity_id == 'device_tracker.A'
        else 'B' }} is {{ trigger.to_state.state }}
  - condition: numeric_state
    entity_id: sensor.000000_average_illumination
    below: '600'
  - scene: scene.abendstimmung
mode: single

In what way does it not work?

What does device_tracker.A show under Developer Tools / States?

Does it work if you manually run the automation, bypassing the trigger and conditions?

If the automation is not running at all, did you check that your automation (‘automation.when i arrive’) is on ?

Thanks a lot now it works!.
There is a device_tracker.A2 and device_tracker.A but only A2 is tracked by HA. Why ever there is a A2.
Nevertheless now it works fine.