Notification for home/away state issues with new person entity

I have an automation to notify me when a person’s state changes from home to away or away to home.

  - alias: a_person_alert
    initial_state: True
    trigger:
      platform: state
      entity_id: person.person1, person.person2, group.presence_guest
    action:
      - service: notify.sms
        data_template:
          #title: "Locale notification"
          message: >
            {{ trigger.to_state.attributes.friendly_name }}{% if trigger.to_state.state == 'home' %} arrived home{% else %} has left{% endif %}.

This automation has been working great for months. However, before I was using “device_tracker” sensors for the entity_ids. Now I am able to add “person” entity_ids.

The previous device_trackers were just based on WIFI connection using the Linksys device tracker component. Since the wifi tracker isn’t always perfectly reliable, I added owntracks as well. So the person entity consists of wifi AND owntracks.

The problem I am having now is that when I leave the house (or anyone else does), I am repeatedly getting notified every few minutes. So this automation will say “person1 has left” over and over again…

This is something to do with the “person” entity because if I just use wifi then it works as expected, and if I look at the history for the OwnTracks entities, it shows properly the comings and goings (no repeated coming and going like the notifications I am getting)…

Is this a bug with the person entity? Or is there something else I can look at?

Check the status of your state.person1, sounds like it’s changing states.
If not and it’s just being updated, you can add this condition:

    condition:
      - condition: template
        value_template:'{{ trigger.to_state.state  != trigger.from_state.state }}'

Yeah, it’s not changing states, that’s why I thought this was so weird… I wonder if the implementation of the person entity is a bit different and continuously updates its state from the contained entities… would make sense that it’s continuously overwriting the state with the same state… hence the continuous notifications…

I’ll add this in, thank you!