Location update is delayed when entering home zone

I am experiencing and issue with zone location updates on android only. Switching from away to home is delayed sometimes upwards of 20 seconds. My wife has an iphone and hers is working fine. More specifically it seems to only be when I am entering the home zone. Leaving the home zone, the location updates within a couple seconds of when I would expect it to.

I have an automation setup to open my garage when I enter the home zone. That automation seems to trigger without delay when my location is updated to home. The issue seems to be that my location does not update when the ā€œzone enteredā€ location is sent from my phone to my home assistant server. Below is how I have determined this.

This is a screenshot of the location tracker in the home assistant app on my android phone. As you will see. The ā€œzone enteredā€ location update was sent at 8:49:51, and again 11 seconds later at 8:50:02. Then a normal background update at 8:50:10

This next screenshot is when the automation to open the garage started. Which was at 8:50:10 when the background update happened

I had my phone out looking when I flipped from away to home status and it was at 8:50:10. So why my location did not update with the ā€œzone enteredā€ location updates, i am not sure. What makes this weird is that is not the case when I am leaving. If i look at the location logs and when the automation to close my garage kicked off. Those line up with the leaving zone location updates. So it seems to only be when entering the home zone.

If there is any other info needed to help troubleshoot that I didnt think of let me know and Ill get that. I am trying to get the logs from the companion app uploaded to this post

At the very least here is what is in the log from the companion app inbetween the timeframe of 8:49:51 and 8:50:10. So when the location should have been updated on my user to when it actual did.

02-14 08:49:51.180 24358 24358 D LocBroadcastReceiver: Received geofence update.
02-14 08:49:51.188 24358 24674 D LocBroadcastReceiver: Last Location: 
02-14 08:49:51.188 24358 24674 D LocBroadcastReceiver: Coords:(xxxxxx, xxxxxxx)
02-14 08:49:51.188 24358 24674 D LocBroadcastReceiver: Accuracy: 5.67
02-14 08:49:51.188 24358 24674 D LocBroadcastReceiver: Bearing: 174.0
02-14 08:49:51.190 24358 24674 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
02-14 08:49:51.190 24358 24674 D LocBroadcastReceiver: Received location that is 61 milliseconds old, 1707918591129 compared to 1707918591190 with source fused
02-14 08:49:51.192 24358 11471 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: false, usesWifi is: false
02-14 08:49:51.196 24358 24674 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: false, usesWifi is: false
02-14 08:49:51.201 24358 14181 D TrafficStats: tagSocket(134) with statsTag=0xffffffff, statsUid=-1
02-14 08:49:51.277 24358 12951 D LocBroadcastReceiver: Event sent to Home Assistant
02-14 08:49:51.520 24358 12951 D LocBroadcastReceiver: Location update sent successfully for 4 as exact
02-14 08:49:52.442 24358 24358 I ViewRootImpl@d5fc0d2[WebViewActivity]: ViewPostIme pointer 0
02-14 08:49:52.486 24358 24358 I ViewRootImpl@d5fc0d2[WebViewActivity]: onDisplayChanged oldDisplayState=2 newDisplayState=2
02-14 08:49:52.521 24358 24358 I ViewRootImpl@d5fc0d2[WebViewActivity]: ViewPostIme pointer 1
02-14 08:49:53.569 24358 24358 I ViewRootImpl@d5fc0d2[WebViewActivity]: onDisplayChanged oldDisplayState=2 newDisplayState=2
02-14 08:49:59.098 24358 24358 I ViewRootImpl@d5fc0d2[WebViewActivity]: ViewPostIme pointer 0
02-14 08:49:59.163 24358 24358 I ViewRootImpl@d5fc0d2[WebViewActivity]: onDisplayChanged oldDisplayState=2 newDisplayState=2
02-14 08:49:59.171 24358 24358 I ViewRootImpl@d5fc0d2[WebViewActivity]: ViewPostIme pointer 1
02-14 08:49:59.621 24358 24358 I ViewRootImpl@d5fc0d2[WebViewActivity]: onDisplayChanged oldDisplayState=2 newDisplayState=2
02-14 08:50:02.184 24358 24358 D LocBroadcastReceiver: Received geofence update.
02-14 08:50:02.189 24358 12951 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: false, usesWifi is: false
02-14 08:50:02.189 24358 11471 D LocBroadcastReceiver: Last Location: 
02-14 08:50:02.189 24358 11471 D LocBroadcastReceiver: Coords:(xxxxxx, xxxxxxx)
02-14 08:50:02.189 24358 11471 D LocBroadcastReceiver: Accuracy: 5.67
02-14 08:50:02.189 24358 11471 D LocBroadcastReceiver: Bearing: 183.0
02-14 08:50:02.191 24358 11471 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
02-14 08:50:02.191 24358 11471 D LocBroadcastReceiver: Received location that is 50 milliseconds old, 1707918602141 compared to 1707918602191 with source fused
02-14 08:50:02.200 24358 11471 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: false, usesWifi is: false
02-14 08:50:02.337 24358 11471 D LocBroadcastReceiver: Location update sent successfully for 4 as exact
02-14 08:50:02.337 24358 29278 D LocBroadcastReceiver: Event sent to Home Assistant
02-14 08:50:10.172 24358 24358 D LocBroadcastReceiver: Received location update.
02-14 08:50:10.173 24358 24358 D ForegrndServiceLauncher: Check if service HighAccuracyLocationService is running. Service running = false
02-14 08:50:10.174 24358 29278 D LocBroadcastReceiver: Last Location: 
02-14 08:50:10.174 24358 29278 D LocBroadcastReceiver: Coords:(xxxxxx, xxxxxxx)
02-14 08:50:10.174 24358 29278 D LocBroadcastReceiver: Accuracy: 5.67
02-14 08:50:10.174 24358 29278 D LocBroadcastReceiver: Bearing: 152.0
02-14 08:50:10.175 24358 29278 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
02-14 08:50:10.175 24358 29278 D LocBroadcastReceiver: Received location that is 27 milliseconds old, 1707918610148 compared to 1707918610175 with source fused
02-14 08:50:10.179 24358 29278 D ServerConnectionInfo: localUrl is: true, usesInternalSsid is: false, usesWifi is: false
02-14 08:50:10.276 24358 29278 D LocBroadcastReceiver: Location update sent successfully for 4 as exact
02-14 08:50:10.350 24358 24358 D SurfaceView@6c7f3e0: 113767392 updateSurface: has no frame
02-14 08:50:10.388 24358 24358 D SurfaceView@6c7f3e0: 113767392 updateSurface: has no frame
02-14 08:50:10.457 24358 24358 I ViewRootImpl@d5fc0d2[WebViewActivity]: onDisplayChanged oldDisplayState=2 newDisplayState=2

each location report the app gets it gets sent to the server, zone entered is when the app gets a geofence entered event from google. that event itself does not mean the actual location in the report is inside the zone, only the HA server determines that. You can verify that by clicking on the map icon. The server itself will mark as you as home or away based on the received GPS coordinates. If you still want it to trigger based on the actual geofence event, then update your automation to also look for the zone entered event as mentioned on this page.

https://companion.home-assistant.io/docs/integrations/app-events

Thank you for the reply. I have one question and one comment.

I just want to make sure I understand you correct. Google can determine I have entered a zone, send my location to HA and HA determine that I am not in the zone? So they wont always interpret my location the same.

if i am understanding you correctly, then it sounds like your saying HA doesnt think im in the zone yet. But then I think there is an issue because HA should think I am. Sometimes I get all the way up my driveway and wait infront of the garage waiting for HA to mark me as home so it runs the automation. The geofence is 100 meters around my house so the update is definitely delayed.

In any case. I will test the app-event doc you linked and see if that helps. Thank you for that

no the app registers your zones as geofences with Google and requests to be updated upon entering/exiting the provided zone details.

the app also registers for background updates which come every 1-3 minutes.

every report the app will receive and you will see some logged data like if its a geofence report or background etcā€¦ those reports are also evaluated to make sure tehy are recent and not duplicated etcā€¦ and then tehy get sent to HA.

HA core will take those reports and determine if you are in the zone or not.

maybe try increasing the zone radius to see if it triggers faster? if you look at the actual report you will probably see its just outside your zone.

in any case you may find this page helpful, a lot of things are detailed here including how to get faster updates using high accuracy mode

https://companion.home-assistant.io/docs/core/location#android-location-sensors

Ok so thanks to your explanation, I think I was able to figure out what the real problem is. I recently attempted to make the home zone radius smaller. Mainly so the garage door would close sooner after leaving the house. I did this by editing my config file and verifying it worked by checking the home zone in the states developer menu. But I dont think my android app changed. I think the app still thought it was at 100 meters when I changed it to 50. So that would make sense as to why my phone would be saying I entered the home zone and the server saying I didnt yet,

When I set the home zone radius back to the default 100 meters. Everything worked as you would expect. So it seems like to me the actual issue is that the android app did not update the geofence with google when I changed the radius. I did go into the app, go to zones, click on the home zone and hit update a hand full of times. Didnt know what else I could try except maybe remove my server from the app and re-add it. Ill play around but I think this is the actual issue here

Oh if you change the zone radius you may need to restart the app or device so it can make a new geofence registration. The registration happens the first time the app loads so quite possible it never updated after you changed it. We do register zones based on the radius provided in the configuration but we donā€™t get updates to that.

The update zone button you see is not app related actually but I can see how it might give a false impression. Generally speaking the dashboard settings may not impact the app completely.

I have tried closing and restarting the app. Restarting the phone. Clearing the app cache. Restarting home assistant. Restarting the VM home assistant is running on. And lastly clicking the update button which sounds like wouldnā€™t do anything for this particular issue.

Just before writing this I tried removing the server, clearing app cache and app data, then re adding the server. So hopefully that does it. Iā€™m sure one way or another Iā€™ll figure it out. And if not I will probably open another thread about it.

Thank you again for the help on this

Not sure what the posting etiquette is, but didnā€™t want to start a new thread, as on the face it my symptoms are similar to the OP.

ā€˜zone leavingā€™ tracking notifications/automations seem to work(ish), or perhaps because they are not so time/distance critical. But zone arrival seem to be hugely delayed.

The automation is the classic ā€˜turn front light when entering a zone (home)ā€™. Often Iā€™m inside my house for the zone status to change to Home.

Itā€™s more annoying as my partnerā€™s Samsung S21 always works, extremely precisely. The app configuration location settings are all default.

Both phones use the same single automation.

Given the above, suspicion as always been something related to my device (Oneplus 6t). I have gone through all the battery/power saving options. Have even tried high accuracy mode with the extended zone.

I am not familiar with logs, but where/what would be the best place to look for to narrow this down? Assuming Iā€™ll need to enter/leave the zone to generate the logs.

There are two logs that are helpful when troubleshooting this. One is your location history and specifically what triggered the location update. That can be found in the mobile app. Hit the 3 bar menu at the top left ā†’ settings ā†’ companion app ā†’ troubleshooting ā†’ location tracking. That will list all the different times your location was sent from your phone to HA. When you are entering a zone it should have an entry in there for ā€œzone enteredā€. My guess is that if you are seeing that location update way later than you expect, like when you get in the house, then from my knowledge, the geofencing is not working properly on your phone. Im not too familiar with the OnePlus phones so im not sure if that would be a google thing or not.

The other log is in settings ā†’ companion app ā†’ troubleshooting ā†’ show and share logs. this will let you email, text, whatever you want, the logs to yourself so you can read them on your computer. you can read them on your phone but its kind of a pain. These will show everything the mobile app is doing. So this is where you would check to see if there is an error with getting your location.

I am assuming that you have both the background location and location zone sensors enabled and have a minimum accuracy of 200.

With the info you have given so far. My guess would be that you are not getting the location updates based on a zone being entered or exited. you are only getting the periodic background location updates. Location log should confirm that

Hi,

Yes, you were correct about the location updates. Seems to only be background - duplicate, sent, not accurate enough. No zone entered/exited (which I have done during this period). What are there duplicates and non accurate ones, seem to get many of those, both in and away from home?

What particular entries should I filtering in the more detailed log?

I cannot pinpoint the issue, but have tried multiple tracking methods, HA, GPS logger, Owntracks, Google Maps. Annoying tracking was working fine when using Life360.

Other notifications (non location based) both in and away from home, come through fine.


The duplicate ones are just when it thinks you havent moved. So the background location updates, its the same coordinates, and it was a close enough time period to the previous location update with the same coordinates that it counts it as a duplicate. this is more so your server doesnt just get hammered with a bunch of updates in a short period of time.

For the not accurate enough ones. There is a minimum accuracy setting in the background location sensor. When a background location is captured, the accuracy of that location is also recorded. The main thing that determines the accuracy of the location is the signal strength of the GPS on your phone. The higher the number, the less accurate it is. If you click on one of those entries that say not accurate enough, it should tell you what the accuracy was. if you have not changed the minimum accuracy in the location sensor then anything over an accuracy of 200 will be skipped. You can increase it up to like 300 or 400 and I would image you would have less location updates being skipped.

Most of what I said there is also outlined in this doc: Location | Home Assistant Companion Docs

One thing of note though, you are getting a lot of location updates. My background location updates happen roughly every 30 seconds. yours seem to be about every 5 seconds. Which seems like a lot to me. In the troubleshooting logs, try filtering to the ā€œLocBroadcastReceiverā€ events and see if any of them are errors

1 Like

that is correct duplicate updates do not get sent for 15 minutes to avoid hammering the server. In my own case moving my phone from the couch to the table may send another update as its not quite a duplicate if my report was accurate enough.

personally speaking mine is at 600 because I noticed valid reports being skipped at home, the current 200 value is a sane default for most users.

5 seconds may suggest high accuracy mode being enabled however i do not see that frequency in the shared screenshots, it looks normal to me but the skipped reports could be causing the issue regarding accuracy.

Thanks to both for your detailed input.

I have read the documentation a number of times over the last couple of months. But perhaps not fully understanding the terminology in context - such as the accuracy value (!). I have now set it to 600. Most are of value 100 and others at about 13/14. A couple were at 500.

I did previously had high accuracy enabled. But not when sending those screenshots. And itā€™s still off.

I have a few pre-configured zone. I ought to see zone entered/exited respectively, correctly.

I go through those zones again and see what it picks up.

Will also later check on the detailed logs.

1 Like

Thought Iā€™d check the detailed logs, but it seems they only go back less than 10 minutes? Is there a max number of entries?

Did a journey about an hour ago. Iā€™m sure I have already checked this a few times before, but this time it was a case of unlocking my phone (when already arrived at home) for the location based to come through, including the front light turning on. Previous times I have left my phone active/screen unlocked all the way, but still random as to when the automations trigger.

Changing the accuracy to 600 caused to flip between showing me as away and home, whilst in side my home. So changed that back to 200.

I am getting some of the zone arrived/exit locations logged, but not all of them, and they are out by a couple of minutes to actual time at location.

logs are only kept for how long the system has the same PID assigned to the app, youd have to keep the app open for a long period of time to get longer set of logs but still no guarantees. You can try using an app like Logcat Reader for more historical logs but no guarantees there either.

this highly suggests the issue is the app does not have proper background access, on some devices its as simple as granting the app background access when prompted. Others like Samsung have many settings hidden that need to be turned off.

Iā€™m not sure the unlocking of screen to get location notifications is consistent.

I get all other notifications - camera, doorbell, contact sensor almost immediately in or out of the home, when the phone has had screen off for hours.

Seems as though the GPS on the phone may be going in to sleep mode.

Even so, I have disabled all power saving options on the phone itself, battery management and for the HA app.

Have also tried the Proximity integration (before and after the UI intro). But that wasnā€™t working on time either.

I can confirm that I am not able to find a 100 percent reliable way of doing zone location updates in a timely fashion.

Since proximity was mentioned, I also gave that a try. I like the concept but sometimes it triggers my automation as im approaching my house and other times I am all the way up my driveway, stopped at the garage door, waiting for it to open. Now I know proximity doesnt use the geofencing, it just monitors how far I am from home, but it still seems inconsistent on when it updates and therefor triggers an automation.

Another reason I tried proximity is because I was still troubleshooting the zone location updates and I noticed I wouldnt always get a location zone entered or exited update. I would only have background updates. For example, I left my home zone, went to another zone and then back home. So I should have had 2 zone entered updates and 2 zone exited updates. The only zone location update I got was the zone exited when I left the house. All other zone updates did not happen.

When the locations do not update on time, I dont see any errors in the logs. or anything that would indicate an issue. Which makes me think the process is working the way it was programmed on the HA side. So it seems to me the issue is either the process the mobile app uses to trigger a zone location update is not optimal, the GPS our phones use have an issue or our expectations on how this technology is supposed to work is incorrect.