In the Android Companion App, I enabled “Location Zone” sensor. All other location sensors are disabled. The application has full location permissions on my phone and battery optimizations are disabled.
Following the Location documentation, my expectation is for the Companion App to detect when I enter/exit a defined zone, and send a location update to HA. However, no location update is sent to HA when I enter a zone (confirmed in Troubleshooting > Location tracking) and as a result, the automations I have configured are not running.
I can see that the Companion App is accessing my GPS data (a green indicator on my phone tells me which app has access to my location). I can also see the my GPS location is accurate (in Google Maps).
As soon as I enable the “Background location”, the Companion App sends a location update to HA and automations are executed.
I don’t want “Background location” to be enabled for privacy reason that are often discussed within the community.
Am I misunderstand the “Location Zone” sensor? is the “Location Zone” unusable without “Background location”?
Read the docs: if you decide not to grant the Home Assistant Companion App location permission or if you subsequently remove the location permissions, no location data will be sent from your device to Home Assistant.
“The paranoia is strong in this one, Jedi.”
“Often discussed”? I read the forum daily and in the past couple of years I can’t recall any such discussion. (For the pedantic among us, I said I haven’t recalled any, not that there is none).
If you turn off “background location”, you have removed location permissions.
All that the “background location” does is- when enabled your GPS is always on. Off saves battery and only enables the GPS if the app that needs it is running. It has nothing to do with security*.
*My phone is Android. I know nothing about Apples.
I turned off the “Background location” sensor, not the Android permission. Sorry, I should’ve been more clear.
Android permissions for the Companion App:
Access to location
Access to location in the background
Access to precise location
Companion App location sensors:
Background location: Disabled.
High accuracy mode: Disabled.
High accuracy update interval: Disabled.
Location zone: Enabled.
Single accurate location: Disabled.
According to the docs, with the above configuration, the Companion App will send location updates to HASS only when a person enters/exits a zone.
Update: this is working for at least a couple of zones that I have, but it’s not working for the default Home zone. The Companion App is not sending a location update to HASS when I enter/exit Home, but it does for other locations. I can confirm from the logs that the Companion App is not receiving an update from Google’s Geofencing service when I enter/exit Home. But I have no idea why at the moment.
When the “Location zone” sensor is enabled in the Companion App, it gets the configured Zones from HASS and then adds them to Geofencing to track enter/exit triggers for them. However, it looks like Home is not a Zone and is not returned to the Companion App when it requests the list of Zones so it’s never added to Geofencing. I haven’t actually confirmed this part but it’s what I suspect after looking into the webhook call the HASS frontend make to fetch all Zones, it returns all Zones except Home.
Maybe I’m missing something, but how is HA to know that you enter a zone when it cannot access your location while running in the background?
But regardless, why are you going to all this trouble to detect home, when the easiest, fastest, and by far most privacy minded way is to ping the device from HA to see if it is there? Or use another router based device tracker?
If the locations you are interested in, making an automation based on the ssid might also be an option.
Ok, this turned out to be wrong. The Companion App also considers the default Home zone for geofencing. I think the enter/exit trigger issues I’ve been having with Home are because of too small radius.
The Companion App can access my location in the background because it has the Android permission “Access to location in the background”.
What I disabled is the “Background location” sensor, which basically tells the app to not continuously send the phones location to HA. Since the “Location zone” is enabled, the app will send the phones location to HA only when entering/exiting a zone.
I agree, there are better ways to detect home. But for other zones, I still depend on the phone’s tracker (Location sensor). What I was trying to figure out is whether HA can detect when someone enters/exists a zone without the phone needing to continuously send location data to HA. That’s because I don’t think our family members need to know exactly where each person is at every moment, but it’s OK if they know someone entered/exited a zone we’ve defined.
To summarize, the above seems to work as expected. I just needed to adjust Home radius.