I have some very functional, very responsive automations that are triggered by (or conditionally controlled by) device location using the HA iOS app.
I’m curious if anyone has come up with a reliable way to determine when two users are together. I think the biggest hurdle is that the devices won’t consistently update at the same time, so the devices may appear to be far apart depending on travel speed, update frequency, etc. Updates occur when entering & leaving significant locations, but there are a lot more other locations than there are zones.
Seeking some inspiration here. Using some precision of GPS coordinates along with time delays might yield something workable, but I think it would take a lot of trial & error. If anyone has done anything like this, I’m interested to learn more.
Ahh yes, thanks. I had a similarly-configured template sensor quite awhile ago. I don’t think I got it from a LinkedIn article, but it was probably the same source. It’s vulnerable to the same update issue I mentioned above… and there may just be no way around it without setting an unreasonably-short update frequency.
But I’ll set up this sensor again and see how it goes.
EDIT: Funny, I have several of these in my templates.yaml file that are commented out. I’m pretty sure I did that last year sometime because they just weren’t meaningful.
OK, I spent some time with this last night. Ultimately, what I’m looking for is a binary sensor that is true/on when two people are together, and off when not. The trouble I was having with the proximity-distance approach is that the automations that are triggered or allowed to run based on distance were inconsistent because of timing: if an automation occurs when one person enters a zone already occupied by another person, well, it’s because the distance has dropped to 0 (or close to it) and maybe some of the automations run, and some don’t… I could likely account for all of it with delays buried in the automations, but I’d rather just set up a reliable binary sensor as defined above.
So my binary sensor should turn on 5 minutes after distance drops below 0.1, correct? It appears to. However, that sensor doesn’t remain true despite the distance staying below 0.1:
The problem obviously lies in my binary sensor. Aside from the toggling all night long when distance remained unchanged at 0, when Person2 left at 8:30-ish this morning (red line), the binary sensor had already turned off again just a few seconds prior. The data shows it better than the visual of the chart.
I want the binary to go true after the defined delay (might tune that later), and go false immediately when defined distance threshold is exceeded. I’ve commented out delay_off to see if that helps… though I think a delay of 0 does nothing. I’m open to ideas on improving this. I think I’m close.
Looks like you have multiple binary sensors, because the one you graph has a name different then the yaml you show. It has the person 1 and 2 reversed.
Ohh–on the chart, I added the names after the fact to obscure the actual sensor names. Pay no attention to that. I have one distance sensor and one binary sensor.
I’ve been running this updated template for the last few hours. It’s accurate when the two people are not together; let’s see what happens when they are:
The idea behind the template delay is that if one person enters the home zone, the location can update more reliably than in other areas. Entering the home zone (or any zone) seems to update more quickly. That might be complicated for no reason… we’ll see. I could probably also just use a not-away on the same sensors so that it updates for any zone.
Due to the scale it is hard to tell if the distance was above .1
While debugging, I’d remove it until you know what happens if it works as expected. Then you can decide based on actual data what would be a good value.
That togging in the first 30 minutes or so was when the delay was still part of the state definition. I don’t know why that would cause toggling… but in any case, this works. I may play with the on delay. I need an on delay to ensure the two devices update within the same window.