Don't send location notifications if both People are in the same location

I have a few notifications based around zones that let my wife and I know when someone is headed home after picking up the kid, or coming home from work, etc.

One annoyance is when my wife and I are together, say leaving my son’s school, and we both get the notification at the same time, saying “Dad is on the way home from school” and “Mom is on the way home from school”.

Yes, yes home assistant… we know. We’re sitting in the same car. LOL

SO… my question for those smarter than me: how do I write the condition that stops the notifiction from firing if our locations are the same? IE: “Don’t notify if G is in the same zone as J. (and vice versa).”

I suspect that the hard part is the fact that notifications are triggered on leaving a zone… so would the condition have to check that we both left that zone at the same time, some how? Or know that we are close to each other (and that kinda depends on when /where owntracks reported locations)? Am I overthinking this? Or is getting this to be a reliable condition going to be a tough one? Should I just deal with the minor annoyance?

I’m using HA for my automations (no node red). Owntracks & NMAP for presence and Person entities. (Nothing special.)

Here’s my current YAML for one such notification:

alias: Location - G Leaving 50H
description: ""
trigger:
  - entity_id: person.g
    event: leave
    platform: zone
    zone: zone.50h
condition:
  - after: "09:00:00"
    condition: time
action:
  - data:
      message: G is on the way home.
      title: Location alert
    service: notify.j

Thanks in advance!

You could use the distance filter in a template condition to require you both to be at least X km apart.

1 Like

I can certainly try it! Nice idea!

If the distance filter doesn’t meet your needs, you could create a template binary sensor that is true when both people are in the same zone, and put a condition in the automation that it has to have been false for X minutes. Something like

{{ states('device_tracker.alice') == states('device_tracker.bob') and states('device_tracker.alice') != 'away' }}

1 Like

This is the kind of thing I was thinking of, just didn’t have the knowledge to pull it off! Between these 2 methods I think you have laid the ground work for me.

Much thanks to you both!

When I have time to drop these into the automation and test, I will update with the workable results.

I ended up using your solution, @atlflyer… it worked more reliably for me than the distance filter so far in testing. (OwnTracks reporting wasn’t as reliable during weekend testing.)

I used “false” for 3 minutes and it worked exactly as it should have with the timing of the pings from our respective OwnTracks apps… Thank you both for the assistantce!