Location not updating on android companion app

Hi all,
A short while ago, my location stopped updating on HA, although I did not change anything on my android phone. It was working find, and one day I noticed all my location based automations stopped working, that is when I noticed my location stopped updating.
After confirming background location access is enabled and no battery saving restrictions on the app, and it still didn’t work, I cleared the app cache and data, and it started working again.
A couple of weeks later, it stopped once more. Did the same trick with clearing cache and data, only this time it didn’t help.
I can see the app is accessing location information on the phone (picture attached). HA is tracking the correct device, but the location doesn’t update.
Any ideas what could be wrong?

Some technical info:

HA version:
Home Assistant 2023.6.3
Supervisor 2023.07.1
Operating System 10.3
Frontend 20230608.0 - latest

Android Companion App version: 2023.6.0-full

Phone: Samsung Galaxy Z Flip4, Android 13, Kernel 5.10.136

Thanks,
Lior.

Have you read the troubleshooting guide?

I have. :grinning:
All was already set up exactly as mentioned in that guide.
Still same issue.

And what about the logs that are part of those steps?

Of course. Here are some related lines from the log (deleted the actual coordinates):

1
07-09 22:40:25.248 18981 18981 D LocBroadcastReceiver: Got single accurate location update: Location[fused hAcc=11.48 et=+13d23h42m57s154ms alt=112.0 vAcc=1.1465485]
07-09 22:40:25.248 18981 18981 D LocBroadcastReceiver: Location accurate enough, all done with high accuracy.
07-09 22:40:25.249 18981 18981 D LocBroadcastReceiver: Last Location:
07-09 22:40:25.249 18981 18981 D LocBroadcastReceiver: Coords:()
07-09 22:40:25.249 18981 18981 D LocBroadcastReceiver: Accuracy: 11.48
07-09 22:40:25.249 18981 18981 D LocBroadcastReceiver: Bearing: 0.0
07-09 22:40:25.249 18981 18981 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
07-09 22:40:25.249 18981 18981 D LocBroadcastReceiver: Received location that is 1062 milliseconds old, 1688931624187 compared to 1688931625249 with source fused
07-09 22:40:25.251 18981 19160 D ServerConnectionInfo: localUrl is: false, usesInternalSsid is: false, usesWifi is: true
07-09 22:40:25.252 18981 18981 D LocBroadcastReceiver: Got single accurate location update: Location[fused hAcc=11.48 et=+13d23h42m57s154ms alt=112.0 vAcc=1.1465485]
07-09 22:40:25.252 18981 18981 D LocBroadcastReceiver: Location accurate enough, all done with high accuracy.
07-09 22:40:25.252 18981 18981 D LocBroadcastReceiver: Last Location:
07-09 22:40:25.252 18981 18981 D LocBroadcastReceiver: Coords:()
07-09 22:40:25.252 18981 18981 D LocBroadcastReceiver: Accuracy: 11.48
07-09 22:40:25.252 18981 18981 D LocBroadcastReceiver: Bearing: 0.0
07-09 22:40:25.252 18981 18981 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
07-09 22:40:25.252 18981 18981 D LocBroadcastReceiver: Skipping old location update since time is before the last one we sent, received: 1688931624187 last sent: {1=1688931625249}
07-09 22:40:25.271 18981 18981 D LocBroadcastReceiver: Received location update.
07-09 22:40:25.275 18981 18981 D ForegrndServiceLauncher: Check if service HighAccuracyLocationService is running. Service running = false
07-09 22:40:25.275 18981 19160 D LocBroadcastReceiver: Last Location:
07-09 22:40:25.275 18981 19160 D LocBroadcastReceiver: Coords:()
07-09 22:40:25.275 18981 19160 D LocBroadcastReceiver: Accuracy: 11.48
07-09 22:40:25.275 18981 19160 D LocBroadcastReceiver: Bearing: 0.0
07-09 22:40:25.276 18981 19160 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
07-09 22:40:25.277 18981 19160 D LocBroadcastReceiver: Skipping old location update since time is before the last one we sent, received: 1688931624187 last sent: {1=1688931625249}
07-09 22:40:25.737 18981 19160 D LocBroadcastReceiver: Location update sent successfully for 1 as exact

This suggests that location updates are working. You’ll want to look at the logs when the issue occurs to see why it didn’t update.

How about this:

07-10 07:02:13.284 29341 29341 D LocBroadcastReceiver: Received location update.
07-10 07:02:13.295 29341 29341 D ForegrndServiceLauncher: Check if service HighAccuracyLocationService is running. Service running = false
07-10 07:02:13.296 29341 29935 D LocBroadcastReceiver: Last Location: 
07-10 07:02:13.296 29341 29935 D LocBroadcastReceiver: Coords:(XXXX)
07-10 07:02:13.296 29341 29935 D LocBroadcastReceiver: Accuracy: 5.67
07-10 07:02:13.296 29341 29935 D LocBroadcastReceiver: Bearing: 306.0
07-10 07:02:13.304 29341 29935 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
07-10 07:02:13.305 29341 29935 D LocBroadcastReceiver: Received location that is 2590 milliseconds old, 1688961730714 compared to 1688961733304 with source fused
07-10 07:02:13.599 29341 19474 D TrafficStats: tagSocket(111) with statsTag=0xffffffff, statsUid=-1
07-10 07:02:23.606 29341 29935 E LocBroadcastReceiver: Could not update location for 1.

In This case the coordinates were accurate and pointing to the correct location, however my HA location was completely wrong.

There is also this from about a minute later:


07-10 07:03:13.212 29341 29341 D LocBroadcastReceiver: Received location update.
07-10 07:03:13.217 29341 29341 D ForegrndServiceLauncher: Check if service HighAccuracyLocationService is running. Service running = false
07-10 07:03:13.218 29341  8354 D LocBroadcastReceiver: Last Location: 
07-10 07:03:13.218 29341  8354 D LocBroadcastReceiver: Coords:(XXXXX)
07-10 07:03:13.218 29341  8354 D LocBroadcastReceiver: Accuracy: 107.064
07-10 07:03:13.218 29341  8354 D LocBroadcastReceiver: Bearing: 0.0
07-10 07:03:13.219 29341  8354 D LocBroadcastReceiver: Begin evaluating if location update should be skipped
07-10 07:03:13.220 29341  8354 D LocBroadcastReceiver: Skipping old location update since time is before the last one we sent, received: 1688961792759 last sent: {1=1688961793171}

Again, the coordinates are accurate, but the location did not update.
My HA location did not update in about a week.

Any suggestions?

Thanks!

was this the only error? there should more just below it as this is a failure

this is valid and expected we dont send old location updates.

was this the only error? there should more just below it as this is a failure

These are the lines that follow (changed IP addresses to XXX.XXX.XXX.XXX):

07-10 07:00:34.630 29341 29935 E LocBroadcastReceiver: io.homeassistant.companion.android.common.data.integration.IntegrationException: java.net.SocketTimeoutException: failed to connect to /XXX.XXX.XXX.XXX(port 8123) from /XXX.XXX.XXX.XXX(port 50762) after 10000ms
07-10 07:00:34.630 29341 29935 E LocBroadcastReceiver: 	at io.homeassistant.companion.android.common.data.integration.impl.IntegrationRepositoryImpl.updateLocation(IntegrationRepositoryImpl.kt:235)
07-10 07:00:34.630 29341 29935 E LocBroadcastReceiver: 	at io.homeassistant.companion.android.common.data.integration.impl.IntegrationRepositoryImpl$updateLocation$1.invokeSuspend(Unknown Source:15)

Thats your answer, server is not responding. Is your HA instance remotely accessible?

Yes. And I have had no trouble accessing it remotely, other than that issue.

accessing the site may work but what about API calls? are you use a proxy or something?

No proxy, I’m using the HA cloud with Nabu Casa cloud subscription.

so its failing locally only?

Well, it shows I’m always home, so my guess it is failing when I’m away.
The above log, with the error, was taken when I was away.
The first log I shared, the one where the location update was successful, was taken when I was at home.

Ok go to settings > companion app > select your server at the top then confirm you have the correct settings there

OK, I have confirmed, settings are correct.
Now, I have changed absolutely nothing, but now it works fine. Confusing.

I’ve been suffering from this too and with the help of this thread I managed to fix it. There can be different reasons for this to happen but in the hope to spare some people endless debugging sessions I wanted to share my case:

The companion app was working just fine (at home and remotely), all the steps in the above troubleshooting guide were checked but it still wouldn’t update the location. The location debugging view would say “Background location - Sending failed” when on the go, but succeed when in the home network. I found some SSL/TLS errors in the app logs which would indicate the background location helper wasn’t able to determine the entire SSL certificate chain despite the app itselfs being able to connect via the SSL nginx proxy just fine. Solution was to manually download and install the intermediate SSL certificate from the issuer and install it on the nginx proxy. This would allow the background helper to succeed with the connection too.

@mzanetti Thanks for that update. I’m having the same problem and am planning on trying your fix. I use Nginx Proxy Manager to provide remote access to my server.

So do I need to download and install the certificate in NPM?

Hey @Valdorama, sorry for the late reply, I was afk for a while.

So in my case the solution was to download the intermediate certificate from my certificate provider (the website where I obtained the SSL certificate also offered a download link for the intermediate cert). Once downloaded, check your /etc/nginx/sites-available/… config file that exposes your home assistant instance and find which SSL certificate file is being used. It’s normally a .pem or a .crt file. Then open that file and paste the intermediate certificate below the actual certificate. The file content should look something like:

--BEGIN CERTIFICATE--
..... (your actual certificate content here)
--END CERTIFICATE--
--BEGIN CERTIFICATE--
..... (your intermediate certificate content here)
--END CERTIFICATE--

Then restart nginx.