Help needed: Home/Garden zone detection is inaccurate

Hi everyone, I’m struggling to get basic zone detection working properly in order to trigger autiomations. Any suggestions gratefully received!

My setup: I have a basic Home zone. I also have presence detection for my phone/tablet/watch using ESP32Cs and the ESPresense integration. These work fairly well with a few problems, and I have a number of automations using these as triggers.

One thing I can’t seem to get right is to detect when I’m in the back garden (which would trigger some other automations e.g. notifying me if there’s someone at the door as I wouldn’t hear it). I usually stay connected to the home wifi while in the garden, but not always.

A few options I’ve considered:

  1. First off, it’s not practical to have an ESPresense node in the garden as I don’t have mains power
  2. I tried detecting a move to the garden triggered by Room Presence changing from Kitchen to Unknown while still connected to wifi, but couldn’t get this to work reliably
  3. My current attempt is to set up a second zone called Back Garden. However, it seems to aggressively place me in Back Garden, even when I am home. More on this below.

This is how my zones are set up. The red circle is where I actually am. The green shape is the rough boundary of my garden. The orange circle is the “Back Garden” zone which I’ve moved ~100m away from the actual back garden for testing. However it still often chooses “Back Garden” as location, even when I am home. [Typically, while I was typing this it has refused to flag me as in Back Garden, so I have moved it closer to the house now for testing purposes]

This is what I see in the entity state

It has detected me as being in both Garden and Home zones, but has prioritized me as in Garden. (A few minutes later and I’m back in the Home zone). If I look at a dashboard with my location history shown, it seems to jump around a bit in the area, but never putting me actually in the garden zone

I’m unsure where to go from here… is there some way to tell Home Assistant “if GPS accuracy is low, and you think I’m in both Garden and Home, always choose Home as the state”? Do I need to change my Location settings in the Companion app? Am I doing this completely wrong?

Also, on a secondary note, I see frequent drop-outs where device trackers intermittently changes to “Away”. This seems to happen most for my wife’s phone, which is an older model, but I also see it on my son’s phone (which quite often seems to disconnect for a lengthy period). If anyone has any pointers on how to diagnose, that would be helpful. It’s a minor annoyance but if all devices drop at the same time my “House Occupied” template sensor incorrectly says the house is unoccupied.

And just to reference, I have looked at this article on optimising mobile location and minimum accuracy and the HA documentation but didn’t find anything that helped me.

My companion settings for my phone are

  • Background Location: Enabled. High-accuracy mode: enabled, High Accuracy only when entering Zones: Home, Garden
  • Location zone: Enabled, minimum accuracy 200
  • Single accurate location: enabled

Whether the app or HA works out which zones you’re in, once in_zones lists both Home and Back Garden, HA sets the tracker’s state to the smallest non-passive zone in that list, which is why Garden wins if it’s the smaller one. Marking Back Garden as passive would keep the state on Home, but the zone stays in in_zones, and the zone trigger and zone condition both check in_zones, so an enter trigger on Back Garden would still fire when an update adds it there. When HA works out the zones itself, a zone is included when the distance to its centre minus its radius is less than the reported gps_accuracy, and over the last 30 days at home my wife’s Android had a median gps_accuracy of exactly 100 m against about 15 m on my iPhone. I don’t have a garden to try this on, so I can’t tell you which setting makes it reliable.

Thanks!

I think the key piece of information I didn’t know is that it selects the smallest zone. I have now shrunk my Home zone and increased my Garden zone, and will see how that behaves.

I would rather not mark Garden as passive as I’d like to see it in the UI.

I’ll post an update here once I’ve had this running for a while, in case anyone else is having the same problems.

Good to hear. One thing though. If Garden is bigger than Home now, the state will show Home when both zones match. But zone trigger and zone condition don’t check the state, they check in_zones. So a zone trigger on Garden will match on more of those bad GPS updates, not less (at least when HA calculates the zones itself). If you want the door notification to follow the state, use a state trigger on the tracker with to: your garden zone name. That one only fires when HA actually picked Garden.