Problem when Person have multiple GPS device_trackers

Hi guys,

I have a problem. I have Person entities who have multiple GPS device trackers. Like OWT, Google and Life360.
I configured an automation that notify when it arrive of leave pre-configured zones.

The problem is that even if the state of the Person is already in a zone, I keep get messages for all the trackers a triggers to the automation. I tried to fix it with templating, but it still triggered multiple times.
I checked and the Person state hasn’t changed, only the device tracker state…

Any idea what am I doing wrong?

This is the automation:

- alias: 'family location notify'
  id: 'familylocationnotify'
  initial_state: true
  mode: queued
  trigger:
    # For Home enter/leave events
    - platform: zone
      entity_id:
        - person.boy
        - person.girl
      event: enter
      zone: zone.home
    - platform: zone
      entity_id:
        - person.boy
        - person.girl
      event: leave
      zone: zone.home
    # For School enter/leave events
    - platform: zone
      entity_id:
        - person.boy
        - person.girl
      event: enter
      zone: zone.school
    - platform: zone
      entity_id:
        - person.boy
        - person.girl
      event: leave
      zone: zone.school
  action:
    - choose:
        - conditions:
            - condition: template
              value_template: >
                {% if trigger.to_state.state == 'School' %} true
                {% else %} false {% endif %}
          sequence:
            - service: notify.ha_notify_me
              data:
                message: "
                {{ trigger.to_state.attributes.friendly_name }} Has Left School
                
                Delivered by {{ trigger.to_state.attributes.source }}.

                "
        - conditions:
            - condition: template
              value_template: >
                {% if trigger.from_state.state == 'School' %} true
                {% else %} false {% endif %}
          sequence:
            - service: notify.ha_notify_me
              data:
                message: "
                {{ trigger.to_state.attributes.friendly_name }} Has Left School
                
                Delivered by {{ trigger.to_state.attributes.source }}.

                "
        - conditions:
            - condition: template
              value_template: >
                {% if trigger.from_state.state != 'home' and trigger.to_state.state == 'home' %} true
                {% else %} false {% endif %}
          sequence:
            - service: notify.ha_notify_me
              data:
                message: "
                {{ trigger.to_state.attributes.friendly_name }} Has Arrived Home
                
                Delivered by {{ trigger.to_state.attributes.source }}.

                "
        - conditions:
            - condition: template
              value_template: >
                {% if trigger.from_state.state == 'home' and trigger.to_state.state != 'home' %} true
                {% else %} false {% endif %}
          sequence:
            - service: notify.ha_notify_me
              data:
                message: "
                {{ trigger.to_state.attributes.friendly_name }} Has Left Home
                
                Delivered by {{ trigger.to_state.attributes.source }}.
                
                "

I suspect the person entity is indeed going in and out of a zone as the various trackers update. This is one of the problems with the person entity - it doesn’t take into account the “last seen” attributes of the trackers. It only cares about last_updated. I.e., a tracker entity may update even if there isn’t new location information. So, e.g., OWT gets new location and updates to be in a zone. This causes the person entity to be in the zone. But then the Google entity is updated (in HA), even though there is actually no new location information, and this entity shows as still outside the zone. This would cause the person entity to update to be back outside the zone. Now the Google entity updates again, but this time with new location information that is inside the zone. So again, the person entity updates and is back in the zone. Hence three zone triggers: enter, leave, enter.

I created a “composite” tracker entity (back in September, 2018) long before the person entity ever existed. I, and many others, have used it for quite some time. It does not suffer from the above described problem because it does use “last seen” attributes from the tracker entities. E.g., I have been using it with Life360 & Google for a long time.

If you’re interested, it’s a custom integration, and you can find it here. If you still want to use the person entities, that’s fine - just use the composite entity as the tracker for the person entity, and the composite will use the three other trackers (OWT, Life360 & Google) as its “input” trackers.

I.e., OWT/Life360/Google -> Composite -> Person.

Thanks @pnbruckner, Ill take a look at it