-
-
Notifications
You must be signed in to change notification settings - Fork 708
high accuracy mode shouldn't turn on while inside zone #4997
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
Comments
Your expected behavior is correct (see example), so this is most likely bug. In Settings > Companion app > Troubleshooting > Location history, you can check all received locations by the app - look for events saying geofence enter/exit, as that is used to toggle the mode on and off. Maybe some expected events are missing. If there are no obvious issues there, could you reproduce the issue and provide the app logs, and more details about the device? You'll want to redact the coordinates in the logs. Then we can maybe find out what the issue is. |
I saw a "zone entered" event in the log when i should already be in the zone, it's marked with a "very old location". don't know what that means |
That means that when the app received the zone event, the location attached to it was >5 min old. The fact that it happened while you were already in the zone shouldn't be a major issue, geofences are expected to have up to a few minutes delay and the location attached to it isn't used for high accuracy mode. Make sure the app is allowed to run in the background/battery usage is unrestricted to reduce those delays as much as possible. Any other zone events? With one there's not much to go on. |
I wasn't being clear enough. There was already a previous zone enter event for that zone. About a couple of hours later, without me going anywhere, there was another zone enter for the same zone, with "very old location". I think high accuracy mode was enabled around that time too (not 100% sure). |
also, is there a way to export the location history? because high accuracy was enabled for hours (hence the bug report), it was sending location every 5 seconds. so there are a huge number of events I have to scroll through every time. edit: oops, too late. the events are already gone :/ |
There is no way to export the location history list. Double checked the code for receiving a zone again but I don't see how that would cause your issue. Unfortunately there isn't really any useful information yet. It would be best if you could open the app, reproduce the issue (you can turn the screen off), and when done get the debug logs from Settings > Companion app > Troubleshooting > Show and share logs. This will be very long but should include precise details for why the app is enabling/disabling high accuracy mode. |
the logs don't go far back enough. i noticed that high accuracy mode turned on in the background and open the app. the logs only started after i opened the app and nothing before that was there. is there another way or do i need to keep the app open at all times? |
also i hit this again and that "Zone entered (very old location)" event correlate exactly with when the high accuracy mode was enabled. again the same thing, "zone entered" first, then about 2 hours later, "zone entered (very old location)" and high accuracy turned on at the same time. |
does this hypothesis make sense:
|
can you check the locations of several reports in the history both before and after that very old event? do they all look correct or do you see any of them jumping around unexpectedly? |
i can see the skipped very old event has i can probably hack around this with a notification command... |
To be clear, best practise is that the high accuracy goes off after configureable time (1min) in home zone. This way homeassistant knows when to open the gate. |
i can confirm this bug with at least 2 seperated installations |
I created this workaround:
|
i don't think anyone has commented on my hypothesis (#4997 (comment)) yet |
the only way to test your theory is to look at the app logs when the issue occurs as we print all the logic there |
@dshokouhi can you tell me how may i get the log? see my comment: #4997 (comment) do i have to keep home assistant in the foreground and force my phone to stay awake all day? what if it doesn't happen with phone forced awake/hass in the foreground? if you are familiar with the logic governing this, can you at least tell me if my theory is something that could happen given the code? |
the logs dont go back that far, depends on the OS when it decides to clear them for our PID, try to install an app like logcat reader so you can look at historical logcat
we log every geofence event we get for this logic so none would be skipped there, we only skip device tracker specific updates we even send an event when this happens: https://companion.home-assistant.io/docs/integrations/app-events the logs tell the best picture here because we can see exactly what the app does, troubleshooting location issues is tricky and that is why we have extensive logging here |
@dshokouhi looks like my hypothesis is exactly right. so, first look at how high accuracy is enabled: android/app/src/full/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt Lines 540 to 548 in eb12d94
here, it uses note these are updated before the zone events are sent to the server. updated here: android/app/src/full/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt Lines 765 to 775 in eb12d94
sent to server later here: android/app/src/full/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt Lines 926 to 927 in eb12d94
however, there are conditions that could prevent this send to happen. what i hit is this one: android/app/src/full/java/io/homeassistant/companion/android/sensors/LocationSensorManager.kt Lines 910 to 914 in eb12d94
(though i believe a "android.zone_entered/zone_exited" event is always sent, but i think that's separate thing from location updates). in summary, zone change caused and IIUC, when high accuracy is enabled, the zone entered/exited events are no longer generated (as they were generated by android's geofence service, which is disabled when high accuracy is running), and disabling high accuracy is solely the server's responsibility. and the server can't do it because it doesn't know the phone has enabled it. |
high accuracy logic is not sent to the server but kept in the app directly, skipped events are for the tracker ad not enabling of high accuracy mode
that is incorrect, the server has nothing to do with high accuracy mode unless you take control yourself and send notification commands |
Because this issue seems to be similar to mine. I've attached my logs. It seems like my app thinks that im in the expanded zone, despite very clearly and accurately being within my regular home zone. Here, at the attached timestamp, I had just enabled "high accuracy when in expanded home zone" from the settings and as you can see, it thinks i'm in the expanded zone. Naturally, I removed any gps coordinates from the logs. The relevant lines should be around Let me know if there's anything I can provide to help with this issue, or if this issue is considered different enough, I can create a new issue |
so the app depends on both events to determine if you are just in the expanded zone or both home and expanded to make the decision, in your logs i can see we only got told about the expanded zone and not the home zone and the app just marks that. This depends on google telling the app about each geofence event and not the coordinates specifically. Testing standing still and toggling the settings may not yield proper results as we probably only got 1 geofence event and not 2. The only way to clear that variable and do a proper check would be to configure high accuracy mode as to your requirements and then force stop and start the app so the geofences can register again and hopefully both events will come. Your logs dont show any geofence events so the app is behaving as expected as it only thinks it is in the expanded zone.
to all others having this issue please let us know what app version you are on, as the original issue was an enhancement we did not get the actual version number impacted |
Unfortunately, I did not manage to capture this while it was in my logs, so all I have is this screenshot of the location tracking section of the logs (started at around 3pm, its 9pm now, so high accuracy mode has been on 6 hours) . I never left home in or near that time, and you can see here that Home assistant is reporting correctly that my phone's gps device tracker has been at home the entire duration of this happening, yet The app gets an old location, sees me entering a zone, and turns on high accuracy mode. I'm not sure how to replicate this behavior so that I can capture the logs while it's still there. Best I have for now is these 2 screenshots that show that this is an issue. I'll try to watch out for this issue so that I can get the logs in time. I'm currently on Version 2025.1.2-full, but I've been having the issue for a long time. |
After making my last comment, I noticed the app disabled high accuracy mode on its own, so I went into the logs and grabbed near that part. I checked all of the coordinates and at all times both before and after high accuracy mode turned off, I was well within the bounds set by home assistant for my home zone. Maybe this can help. The first report of high accuracy mode being disabled is at 03-24 21:09:56.136 |
I finally managed to catch the issue starting in the logs. I get a zone entered entry at 18:18:10 and high accuracy mode turns on. I've been within my home zone the entire time. The app version is 2025.1.2-full homeassistant_companion_log_3-1-2025_19-32-22.txt Please let me know if this is of any help |
Here's one more log of the issue occurring. Hopefully this can help |
Steps to reproduce
Expected behavior
When I am far away from the selected zone, high accuracy should be off. When I get within 300m of the zone, high accuracy should turn on. After I have entered the zone, it should turn off.
Actual behavior
High accuracy stayed on after I have entered. Sometimes, it even turns itself on when I am inside the zone.
The text was updated successfully, but these errors were encountered: