Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High accuracy location doesn't trigger on zone only when "Location Zone" is enabled but work if disabled #4892

Open
arsenicks opened this issue Dec 10, 2024 · 27 comments
Labels
bug Something isn't working location-tracking question Further information is requested

Comments

@arsenicks
Copy link

Home Assistant Android app version(s):
2024-12-1-full

Android version(s):
14

Device model(s):
Galaxy S23

Home Assistant version:
Core: 2024.12.1
Supervisor: 2024.11.4
Operating System: 14.0
Interface utilisateur: 20241127.6

Last working Home Assistant release (if known):
N/A was working with older phone(Galaxy S20) but I might have used BT+zone or BT alone can't recall.

Description of problem, include YAML if issue is related to notifications:
I want to enable high accuracy location when I'm about to enter and when in one specific zone. This was working pretty great with my old phone but since I switched to the new one I'm having problem, might be settings related, device or simply a bug. All battery optimisation for companion app are disabled. So here's the background location settings with trigger range:
image

As you can see here, even if I was parking within 300m of my house(within the 600m trigger range zone) the high accuracy sensor report false(red). You can see the "Location Zone" setting is also enabled, according to the documentation it's required.
image

If I disable the "Location Zone" settings the high accuracy sensor is true, see here:
image

I tried with zone.home and with another zone that cover my neighbour with the same result. (neighbour(home))

Additional information:
From all the tests I did, it just looks like the zone are simply not used at all, I can set high accuracy mode to bluetooth device and it work, if I set bluetooth device + a zone, can't get that to trigger. At first I tough it could be related to my vpn being on and maybe the app was using local url and considered I was home but so far disabling it didn't change anything.

@arsenicks arsenicks added the bug Something isn't working label Dec 10, 2024
@dshokouhi
Copy link
Member

Please get the logs those are critical for troubleshooting. It may be difficult to get proper logs but you may first refer to location tracking history find under settings > companion app > troubleshooting

@dshokouhi dshokouhi added question Further information is requested location-tracking labels Dec 10, 2024
@arsenicks
Copy link
Author

Hi, thanks for your reply! Sure, I enabled it I realized that I kept bluetooth only enabled when coming home so the high accuracy was enabled.. I should be able to upload relevant log tomorow when coming from work.

What format do you want ? like a screenshot of the location tracking history section or you'll need more details ? As far as I can see, I can only get details one by one, is there a way to export multiple "location update" together or to get those debug log on the server side ?

Thanks again, have a nice one!

@dshokouhi
Copy link
Member

do you see zone entry/exit events? are they failing to send?

@arsenicks
Copy link
Author

Hi, right now I only have logs for this morning while exiting zone.home, I don't know if this will help. I can see location has been sent, exit zone too but when I look at my high accuracy sensor it didn't went on since yesterday.

From my understanding it should have triggered when leaving home untill I exit the 600m(trigger range zone) outside zone.home right?

Config:
Screenshot_20241210_082051_Home Assistant

High accuracy sensor history:
Screenshot_20241210_083113_Home Assistant

Tracking logs while leaving home:
Screenshot_20241210_081850_Home Assistant

Details of two logs that seamed relevant:
Screenshot_20241210_082301_Home Assistant

I'll report back when coming home but I think exiting should react the same as "coming to" a zone with trigger range zone. Let me know if you need anything!

@dshokouhi
Copy link
Member

From my understanding it should have triggered when leaving home untill I exit the 600m(trigger range zone) outside zone.home right?

no only triggers 600m AWAY from home zone and turns off once inside it.

https://companion.home-assistant.io/docs/core/location#zone-when-using-the-high-accuracy-mode-trigger-range-for-zone-meters-option-value-greater-than-0

all your messages are sent successfully so there are no issues there. Sounds like maybe a misunderstanding of the feature or Google is not updatig your zone info fast enough which the app cannot fix. We ask for updates and wait for them to be sent to us.

@arsenicks
Copy link
Author

Ok, i just came back home, I'll update later with screenshots and logs the high accuracy never triggered while coming home but yes location is sent correctly it just doesn't switch to high accuracy when entering the trigger range zone which is the desired behavior.

@arsenicks
Copy link
Author

arsenicks commented Dec 10, 2024

16:21 leaving from work
image

16:23 at the red light near my house, at this point I'm probably already within the trigger range zone of 600m otherwise I should have entered around that time.
image

16:25 In a parking lot at around 400m of my house to see if high accuracy sensor is true.
image

Full location history around that time:
image

high accuracy sensor hasn't triggered since yesterday:
Screenshot 2024-12-10 18 51 09

@dshokouhi
Copy link
Member

Ok at this point every call is successful. We need to see logs from the same troubleshooting section when the issue happens so we can see what the decision making process is there. It all depends on the data received at Google.

@arsenicks
Copy link
Author

Allright, is there a way to send you the logs directly I would prefer to not disclose publicly the coordonate of my logs! I can send you by email if you want, otherwise I can just remove the exact coordinate from the logs and put them here if you think it's not relevant for the debug.

@dshokouhi
Copy link
Member

you can just mask the coordinates and your URL that is the only identifiable info in there.

@arsenicks
Copy link
Author

Allright I'll try to keep that readable!

One log before the one that seems relevant:

Created: 2024-12-10 16:23:59.755
Trigger: FLP_BACKGROUND
Result: SENT
Data: UpdateLocation(gps=[46.X, -71.X], gpsAccuracy=5, locationName=null, speed=3, altitude=28, course=138, verticalAccuracy=0)

Location: 46.X, -71.X
Accuracy: 5
Server: Maison 

First relevant I see is this one. We can see the trigger GEOFENCE_ENTER. I'm still far from home so this is not the zone.home triggering, it looks like this is the trigger rangezone getting fired. If I check the coordinate and measure on google map I'm at ~634m from home moving in my car so that would make sense.

Created: 2024-12-10 16:23:59.808
Trigger: GEOFENCE_ENTER
Result: SENT
Data: UpdateLocation(gps=[46.X, -71.X], gpsAccuracy=5, locationName=null, speed=2, altitude=28, course=142, verticalAccuracy=0)

Location: 46.X, -X
Accuracy: 5
Server: Maison 

next log:

Created: 2024-12-10 16:24:24.870
Trigger: FLP_BACKGROUND
Result: SENT
Data: UpdateLocation(gps=[46.X, -71.X], gpsAccuracy=5, locationName=null, speed=3, altitude=33, course=134, verticalAccuracy=0)

Location: 46.X, -71.X
Accuracy: 5
Server: Maison 

Additional info, my proximity sensor report a little bit farther but that might lag.. That's the sensor I used to trigger automation when coming home and it was pretty accurate when high acccueracy was on:
image

Thanks for your patience and your help, let me know if I can give you other usefull logs!

@dshokouhi
Copy link
Member

sorry not those logs, go back one page

settings > companion app > troubleshooting > show and share logs

where you are in relation to hte events received does not matter....Google will send the app an update and we have some logic to make sure its fairly recent and accept and send it. Each location report includes the time of the event that we use to evaluate how current it is. The logs above will show that decision making process.

@arsenicks
Copy link
Author

Oh! ok, from what I can see the oldest logs in there now are from 19h30 so I'll have to go out and retest to generate new logs. I'll update you whenever I can do it!

@dentex
Copy link

dentex commented Dec 11, 2024

Hi, this is just to report that I have the same issue or at least a very similar one: zone entering is not triggering or high accuracy is not triggering when entering specific zone. It's happening since a few days. All the configuration remained the same, in the meantime. Same phone (pixel6, rooted) with latest android 15. Maybe an app update broke something? I'll provide more info (screenshots and logs) ASAP.

@dshokouhi
Copy link
Member

Hi, this is just to report that I have the same issue or at least a very similar one: zone entering is not triggering or high accuracy is not triggering when entering specific zone. It's happening since a few days. All the configuration remained the same, in the meantime. Same phone (pixel6, rooted) with latest android 15. Maybe an app update broke something? I'll provide more info (screenshots and logs) ASAP.

are you seeing large gaps in the location tracking history? some users are hitting #4679 which we suspect to be a play services issues which is impacting many other apps like Owntracks.

also when you say rooted did you change the ROM? if so that is unsupported.

@dentex
Copy link

dentex commented Dec 11, 2024

are you seeing large gaps in the location tracking history? some users are hitting #4679 which we suspect to be a play services issues which is impacting many other apps like Owntracks.

No gaps... It's just that zone location has completely stopped working and I have to figure out what I changed. My impression it's that I did nothing ...

also when you say rooted did you change the ROM? if so that is unsupported.

No, I have a stock ROM. Root is gained via Magisk. The device has root since day 1. No issues ever with Home Assistant and it's companion app. I also don't think the two things are related in any way (although I can understand why the mantra is "if you have root, then it's not supported")

I took some screenshots. Some text it's in Italian though.
Screenshot_20241211-212755
Screenshot_20241211-212152
Screenshot_20241211-212103
Screenshot_20241211-214421
Screenshot_20241211-214852

I'm at work location now ("lavoro") and there's no way I can trigger the accurate location to fire. Location history shows the accurate position as sent, but it's not reflected in any entity.
If I disable location zones, high accuracy gets the true value, but the location seems not reflected anyway.
("High accuracy only when entering zone" is disabled in the screenshot, I was making some tests, but it has always been enabled)

@dshokouhi
Copy link
Member

but it's not reflected in any entity.

check the server, some entity 100% got an update if you see the green checkmark.

also please disable the option for single accurate to be included in sensor updates, probably causing some conflict

@dentex
Copy link

dentex commented Dec 11, 2024

check the server, some entity 100% got an update if you see the green checkmark.

also please disable the option for single accurate to be included in sensor updates, probably causing some conflict

Ok option disabled, but no changes...
I'm going to do some extensive testing tomorrow... I'll try to find some older apk also.

Thanks for taking a look!

@dentex
Copy link

dentex commented Dec 12, 2024

I confirm the issues also with older version of the app (September). It might depend on some Google services?

@arsenicks
Copy link
Author

sorry not those logs, go back one page

settings > companion app > troubleshooting > show and share logs

where you are in relation to hte events received does not matter....Google will send the app an update and we have some logic to make sure its fairly recent and accept and send it. Each location report includes the time of the event that we use to evaluate how current it is. The logs above will show that decision making process.

Ok, here's the timeline:
12:41-42 leaving house/home
This time high accuracy mode worked while leaving zone.home within trigger range zone
~12:45 leaving 600m trigger range zone
~12:51 coming back home
~12:57 arrived home

I can see now when I left the house the high accuracy mode triggered(while leaving home but within the 600m radius) but it hasn't triggered when coming back. I hope I was able to remove any personal info from there..

Additionnal info: I have two automation on my phone that could cause weird things in the logs:
1- When connecting to my car bluetooth wifi turns off, you'll see bluetooth event and wifi disconnect around 12:42:39 this is normal
2- when not on home wifi wireguard vpn turns on and all my traffic goers through the vpn (default gw through vpn). So you may see localurl true.

See attached files.
Screenshot_20241212_125910_Home Assistant
debug HA android app.txt

@dshokouhi
Copy link
Member

looks like we simply did not get a geofence event from google so we could not turn it on. The app depends on that for the feature work properly.

offtopic:
your logs have tons of websocket errors for timeouts which is not related but something you may want to consider fixing on the server end

strange i do see the ping responses but not sure why the other calls timeout.

@arsenicks
Copy link
Author

looks like we simply did not get a geofence event from google so we could not turn it on. The app depends on that for the feature work properly.

Ok so, I'll try to read and try to find an explanation to this is this what you use in the companion app ? https://developers.google.com/android/reference/com/google/android/gms/location/GeofencingEvent

Sometimes it seems to trigger other not and from what I understand it depend on google, is there anyway around them ? I mean I want to keep things simple and I was happy to use the companion app feature but should I consider using another app ? From the top of my head I guess I could used tasker/automate to enable the high accuracy mode when coming into home range but I guess it will use pretty much the same geofence event ?

offtopic: your logs have tons of websocket errors for timeouts which is not related but something you may want to consider fixing on the server end

Fixed thanks for pointing that out, it looks like it was a widget for the pool temperature but it's winter now, the device is turned off ;)

strange i do see the ping responses but not sure why the other calls timeout.

I guess this is related to the geofence event ? If so my vpn was turned on, if you think this could have an impact I could try to disable it and test again. While saying that it makes me think... Like I said I have an automation on my phone that turns wifi off when my phone is connected to car bluetooth because when leaving the house the wifi was staying connected for a while but the connection wasn't good enough to work...

I really have no idea of the inner working of the wifi and location but looking at this android doc

Wi-Fi is turned off on the device. Having Wi-Fi on can significantly improve the location accuracy, so if Wi-Fi is turned off, your application might never get geofence alerts depending on several settings including the radius of the geofence, the device model, or the Android version. Starting from Android 4.3 (API level 18), we added the capability of “Wi-Fi scan only mode” which allows users to disable Wi-Fi but still get good network location. It’s good practice to prompt the user and provide a shortcut for the user to enable Wi-Fi or Wi-Fi scan only mode if both of them are disabled. Use SettingsClient to ensure that the device's system settings are properly configured for optimal location detection.

From what I can see “Wi-Fi scan only mode” is enabled on my phone but I'll disable my wifi and vpn automation an do another test later today.. I feel like this could be related, I didn't have those automation on my old phone.. If you have any other idea let me know!

@arsenicks
Copy link
Author

I did few more tests and it seems to work better with wifi enabled but it didn't work every single time, maybe 2/3 so it's better but I can't really say it's fixed, something still weird..

@dshokouhi
Copy link
Member

do you have wifi and BT scanning enabled and both left on?

i still feel this is a play services issue if we are not getting the events properly

@arsenicks
Copy link
Author

Yes both are on. Honestly I feel something is weird and play service could be the source of the problem but I don't know how can I digg deeper into that debug session.. I might try during my vacation to enable the same setting on my girldfriend phone to see if I get the exact same behaviour. Between that time feel free to close the issue if you think this is not a bug, I'll just come back later and reference this one if I ever find a cause.

Thanks for your time!

@dentex
Copy link

dentex commented Jan 10, 2025

A few days ago I installed the companion app on a new device, a pixel 7, and everything works as intended... But the same settings on the pixel 6 gives no zone entering triggering... I might cross check what versions they have in regards to android os and Google services, if this might help.

@dentex
Copy link

dentex commented Jan 11, 2025

I fixed my issue. Looking into settings -> devices and services -> integrations -> app for mobile devices (I'm translating from Italian strings, some wording might be different) I had multiple instances for my mobile phone. I deleted all of them through various HASS restarts, since something was hanging in a "not reloaded" state, but in the end after reconnecting the companion app with the server, everything returned to work.

Screenshot_20250111-145808

@arsenicks you may want to check if you have your mobile phone listed multiple times.

Since the issue was on the server side, this explains why the device was correctly sending positions, as seen in the logs, but no zone entering was triggered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working location-tracking question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants