New Android device does not keep connection info between uses with the companion app

Just upgraded to a new phone. Went from a Samsung S20 to a Samsung S21. Reinstalled the Android HA companion app.

The app does not seem to remember the connection details. Everytime I reopen the app on the phone I have to type in the connection URL and log back in. Once in, I can access all the features of the app as normal. I have also noticed that I cannot set the device name in the app configuration settings on the app and the device never shows on the Integrations list. None of this was a problem on my previous phone.

Phone is Android 12
App is Android version 2022-1.1-full

I have removed all the old integrations for the old phone and restarted the HA instance just to be sure that was not causing any conflicts. I have also deleted all data and cache and reinstalled the mobile app several times.

Anyone else have this issue? Or can point me to existing thread (I tried searching and could not find similar issues) that I can research. And I can certainly provide detailed logs and reports but wanted to see if there was a quick answer first.

device never shows on the Integrations list

If the integration does not show up, add it manually. The bottom right corner choose add → mobile app, enter the IP of the phone.

Thanks for the rapid response. I tried as you suggested but get a modal box that does not allow for the integration to proceed.
2022-01-21 11_46_04-Home Assistant

Of course I can open the mobile app on my phone and add the instance URL and I get a sign-in box. But as stated before, as soon as I dismiss the app and go back to it I have to enter the URL again.

This was never an issue with the older Samsung S20 which was running Android 11. I am just wondering if there is some security or safety setting in 12 that did not exist in 11.

If you go to where you would clear the cache, there is another option for permissions. You can look there to see what permissions you have. I have files and media, location, nearby devices, phone and physical activity. Btw I am running 12 without this problem.

Did you happen to restart ha after removing the original integration?

Clearing data is correct but reinstalling the app triggers auto back which can bring back bad data. You can only create a mobile app integration by logging into the app.

Try these steps in order:

if that fails and its not saving the data then yes we need to see the logs in Companion App to see what hte failure is.

1 Like

Yes. Have restarted HA a few times during this process.

Hey, I’m experiencing the same exact issue. In fact, I’ve never seen the application working in my life. This is on a Pixel 3, and it happened running Android 11 and 12, which I just installed now.

Every time I open the App it asks me for the HA URL as if it was the first time.
Once I login (through https, with a legit cert but in a non-reachable IP) I can use HomeAssistant normally.

Then I try to register the device, and it does not work. No “App” integration appears in HA; and even in the App, if I go to the previous menu and then get in again, the device name I entered is forgotten and it reads “No name”.

Captured the logs of these attempts, and I see the App is logging some 404s when trying to register the device. Logs here. Relevant entries read as follows:

01-21 23:40:59.843 22215 22215 D UrlRepository: localUrl is: false and usesInternalSsid is: true
01-21 23:40:59.849 22215 22215 D UrlRepository: localUrl is: false and usesInternalSsid is: true
01-21 23:40:59.849 22215 22215 D UrlRepository: Using external URL
01-21 23:40:59.936 22215 22215 D UrlRepository: localUrl is: false and usesInternalSsid is: true
01-21 23:40:59.936 22215 22215 D UrlRepository: Using external URL
01-21 23:40:59.938 22215 22215 D UrlRepository: localUrl is: false and usesInternalSsid is: true
01-21 23:40:59.938 22215 22215 D UrlRepository: Using external URL
01-21 23:40:59.988 22215 22215 E IntegrationRepository: Unable to register device
01-21 23:40:59.988 22215 22215 E IntegrationRepository: retrofit2.HttpException: HTTP 404 
01-21 23:40:59.988 22215 22215 E IntegrationRepository: 	at retrofit2.KotlinExtensions$await$2$2.onResponse(KotlinExtensions.kt:53)
01-21 23:40:59.988 22215 22215 E IntegrationRepository: 	at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:161)
01-21 23:40:59.988 22215 22215 E IntegrationRepository: 	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
01-21 23:40:59.988 22215 22215 E IntegrationRepository: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
01-21 23:40:59.988 22215 22215 E IntegrationRepository: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
01-21 23:40:59.988 22215 22215 E IntegrationRepository: 	at java.lang.Thread.run(Thread.java:920)

This makes me think the App tries to access a resource in HA which does not seem to exist. I’m still trying to pinpoint which is the HA URL being hit.

I’d suggest you to give a look to the App logs; this can be done from Configuration, Companion App, Show and Share Logs (near the bottom) and I’d appreciate if you share those logs too.

This is really strange. Can you do me a favor and run through the steps I linked above in order please? Look at the logs immediately after following these steps to see if this 404 error is still there. The reason why I ask you to follow those steps is because we want to avoid auto backup even if the app never worked. Also are you using a proxy or anything? If so bypass it temporarily and do a direct connection to rule out a network related issue. Make sure to also look at the logs in HA core too, there may be a clue there.

Hey @dshokouhi,

I followed those steps quite a few times already. Will do that again, leaving a note of the state between every step:

  1. Check that Home Assistant Core, the Android app and Android System WebView are up to date.

Yes, they are. Running HomeAssistant 2021.12 Docker Image; the Android app was freshly downloaded and System WebView does not have any pending update. Did not attempt to connect yet.

  1. Clear Storage or App data in Android app.

Done. Removed 69MB of user data and 18MB of cache.
I opened the app, got asked for the URL, entered my https URL and I was asked for username and password. Here it does not really change which method I use, I have a few: trusted networks, Legacy API Password and Username-Password. I log in with Trusted Network. Pick my username and click next.

Then the App asks for the device name. I leave “Pixel 4a” in the box, and enable location tracking. Android asks me for location permissions and I grant them all.

At this stage I’m also looking at the HA logs in the terminal and I expect that, upon clicking Finish, the App will try to register my device.

Upon clicking Finish, HA logs this:

2022-01-22 10:54:26 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from Pixel-4a (192.168.1.226). (HomeAssistant/Android Pixel 4a 2022.1.1-1890)

So will try again, but using Legacy API Password instead of trusted networks. I did not flush the App cache. Closed the App, restarted the flow. After entering the URL, HA logged this:

2022-01-22 10:57:07 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow/0884d9124d33495b80742c390ced8ef2 to 192.168.1.226 (auth: False)
[homeassistant.components.http.view] Serving /auth/token to 192.168.1.226 (auth: False)
2022-01-22 10:57:18 DEBUG (MainThread) [homeassistant.components.http.auth] Authenticated 192.168.1.226 for /api/mobile_app/registrations using bearer token
[homeassistant.components.http.view] Serving /api/websocket to 192.168.1.226 (auth: False)
2022-01-22 10:57:19 DEBUG (SyncWorker_0) [homeassistant.helpers.storage] Writing data for auth to /config/.storage/auth

The last line looks interesting to me.

Tried again, here are the relevant logs from HA:

2022-01-22 11:03:05 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow/1618eb96bf7140d9823dd319c8369302 to 192.168.1.226 (auth: False)
2022-01-22 11:03:05 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.1.226 (auth: False)
2022-01-22 11:03:11 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow/3ef8ba9785834d11860e33047e4ed9c7 to 192.168.1.226 (auth: False)
2022-01-22 11:03:11 DEBUG (SyncWorker_2) [homeassistant.util.json] JSON file not found: /config/.storage/auth_module.totp

The last line looks interesting to me.

  1. In Home Assistant navigate to the Integrations Dashboard. Remove the mobile app entry for the device in question. If you see more than 1 remove them all.

I don’t see any mobile integration. As a matter of fact, I’ve never seen any mobile integration, I have no idea how they look like and to me they have always been a myth, LOL.

  1. Restart Home Assistant.

Did it many times during the testing flow.

  1. Log back into the Android app. If you have more than 1 device, make sure to rename the device during onboarding.

Did it many times during the testing flow.

They key part to me is this:

2022-01-22 11:31:44 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/providers to 192.168.1.226 (auth: False)
2022-01-22 11:31:44 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.1.226 (auth: False)
2022-01-22 11:31:46 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow/82c5cb4b1cfc4c2798944b60edbdfe18 to 192.168.1.226 (auth: False)
2022-01-22 11:31:46 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.1.226 (auth: False)
2022-01-22 11:31:47 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow/fcb18733b0634995a57c1e8964e328d6 to 192.168.1.226 (auth: False)
2022-01-22 11:31:51 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/token to 192.168.1.226 (auth: False)
2022-01-22 11:31:51 DEBUG (MainThread) [homeassistant.components.http.auth] Authenticated 192.168.1.226 for /api/mobile_app/registrations using bearer token
2022-01-22 11:31:51 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.226 (auth: False)

The flow shows the request made from Pixel 192.168.1.226 during the Auth flow. First, receiving the list of authentication providers, then passing through the flow, always with Auth: False. Then It says “Authenticated”, so from that moment on I expect all request to be served with Auth: True.

However when the socket is requested, the Auth value is still False; as if I was not logged in. That being said, I can access all features of Home Assistant, as if I was logged in. In the left menu bar I see I’m logged in too, it shows the username.

Assuming the problem is related to how the App-HA handle user session information, I noticed that upon changing the “Advanced mode” switch in the App, HA logs this:

2022-01-22 11:38:45 DEBUG (SyncWorker_1) [homeassistant.helpers.storage] Writing data for frontend.user_data_77585086aafc4c1687f5bf36ba32d389 to /config/.storage/frontend.user_data_77585086aafc4c1687f5bf36ba32d389

So I have the feeling the App is logged, but not “fully” logged in, as other requests appear as “Auth: False”

Hope we’ll manage to nail it because it seems some people is missing a great HA feature :slight_smile:

So you already started skipping steps after step 2.

The goal is to login after checking the integrations tab to remove any mobile app integrations. You made all these attempts before hand so when I said please dont skip a step you did exactly that :wink: The login attempt should be done at step 5 when it says to.

You also did not get the on device logs after logging in so we are missing key pieces of information here. When I said look at the logs up above I was referring to the same log location as when you posted the 404 error. The goal is to see if that 404 error shows up during initial onboarding and to look at the logs above and below it to see what happened.

I’ve restarted HA -stopped and started the container- in between attempts; despite not being noted. I needed to because I was disabling the logging of different components on every attempt to reduce the noise in the logs. Same as checking the Integrations tab; I’ve never had any mobile integration popping up.

And yes, the logs in the App have always been the same shown in the first logs I posted:

  • 404 for device registration attempts
  • 403 for getting the rate limit for notifications

I understand you are trying to be helpful and to fix the issue but I am trying to be precise in what I am looking for in order to troubleshoot your issue. I cant help you if you dont provide the information I am looking for.

Logs tell a story and without looking at the onboarding flow with the log output I am fighting blind.

I need to see the on device logs from when you perform those steps. Otherwise I have no idea where its specifically failing in the code.

I tried to be pretty specific here.

You also forgot to mention anything about this part.

Followed the steps exactly as you mentioned, results are still the same. Did only as “Trusted networks” and then using the only user I have - legacy user.

So, when I login from the computer, the “Auth” value of the flow changes, here are the request for .148:

2022-01-22 13:04:46 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/providers to 192.168.1.148 (auth: False)
2022-01-22 13:04:46 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.1.148 (auth: False)
2022-01-22 13:04:48 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow/07a93f27d6e5428da4172b217b6e2622 to 192.168.1.148 (auth: False)
2022-01-22 13:04:48 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.1.148 (auth: False)
2022-01-22 13:04:50 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow/10a17f352f4048b89715432cc20b5fb3 to 192.168.1.148 (auth: False)
2022-01-22 13:04:50 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/token to 192.168.1.148 (auth: False)
2022-01-22 13:04:50 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.148 (auth: False)
2022-01-22 13:04:50 DEBUG (MainThread) [homeassistant.components.http.auth] Authenticated 192.168.1.148 for /api/config/config_entries/entry using bearer token
2022-01-22 13:04:50 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/config/config_entries/entry to 192.168.1.148 (auth: True)
2022-01-22 13:04:51 DEBUG (SyncWorker_1) [homeassistant.helpers.storage] Writing data for auth to /config/.storage/auth
2022-01-22 13:04:53 DEBUG (MainThread) [homeassistant.components.http.auth] Authenticated 192.168.1.148 for /api/config/config_entries/entry using bearer token
2022-01-22 13:04:53 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/config/config_entries/entry to 192.168.1.148 (auth: True)

When logging in the App, using the local IP as host with port 8124, the App never manages to get “Auth: True”, even after the “authenticated IP for …” line:

2022-01-22 13:06:00 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/providers to 192.168.1.226 (auth: False)
2022-01-22 13:06:00 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.1.226 (auth: False)
2022-01-22 13:06:03 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow/a3548c82d754466181f7eab12b72f32b to 192.168.1.226 (auth: False)
2022-01-22 13:06:03 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow to 192.168.1.226 (auth: False)
2022-01-22 13:06:04 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/login_flow/17d875981f8447c28cdc15966a02543e to 192.168.1.226 (auth: False)
2022-01-22 13:06:11 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/token to 192.168.1.226 (auth: False)
2022-01-22 13:06:11 DEBUG (MainThread) [homeassistant.components.http.auth] Authenticated 192.168.1.226 for /api/mobile_app/registrations using bearer token
2022-01-22 13:06:12 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.226 (auth: False)
2022-01-22 13:06:12 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 192.168.1.226 (auth: False)
2022-01-22 13:06:12 DEBUG (SyncWorker_3) [homeassistant.helpers.storage] Writing data for auth to /config/.storage/auth

And here are the logs of the App for the setup flow:

01-22 13:06:10.820  9572  9572 D UrlRepository: localUrl is: false and usesInternalSsid is: false
01-22 13:06:10.824  9572  9572 D UrlRepository: localUrl is: false and usesInternalSsid is: false
01-22 13:06:10.824  9572  9572 D UrlRepository: Using external URL
01-22 13:06:10.904  9572  9572 D UrlRepository: localUrl is: false and usesInternalSsid is: false
01-22 13:06:10.904  9572  9572 D UrlRepository: Using external URL
01-22 13:06:10.905  9572  9572 D UrlRepository: localUrl is: false and usesInternalSsid is: false
01-22 13:06:10.905  9572  9572 D UrlRepository: Using external URL
01-22 13:06:10.960  9572  9572 E IntegrationRepository: Unable to register device
01-22 13:06:10.960  9572  9572 E IntegrationRepository: retrofit2.HttpException: HTTP 404 Not Found
01-22 13:06:10.960  9572  9572 E IntegrationRepository: 	at retrofit2.KotlinExtensions$await$2$2.onResponse(KotlinExtensions.kt:53)
01-22 13:06:10.960  9572  9572 E IntegrationRepository: 	at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:161)
01-22 13:06:10.960  9572  9572 E IntegrationRepository: 	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
01-22 13:06:10.960  9572  9572 E IntegrationRepository: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
01-22 13:06:10.960  9572  9572 E IntegrationRepository: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
01-22 13:06:10.960  9572  9572 E IntegrationRepository: 	at java.lang.Thread.run(Thread.java:920)
01-22 13:06:11.016  9572  9572 D RenderScript HIDL Adaptation: IRenderScriptDevice::getService()
01-22 13:06:11.017  9572  9572 D RenderScript HIDL Adaptation: IRenderScriptDevice::getService() returned 0x0
01-22 13:06:11.017  9572  9572 D RenderScript HIDL Adaptation: Using Fallback Path.
01-22 13:06:11.027  9572  9572 D mpanion.androi: Successfully queried cache dir: /data/user_de/0/io.homeassistant.companion.android/code_cache
01-22 13:06:11.027  9572  9572 D RenderScript: Setting cache dir: /data/user_de/0/io.homeassistant.companion.android/code_cache
01-22 13:06:11.031  9572  9572 I System.out: recordForce value 6
01-22 13:06:11.032  9572  9572 D WebviewActivity: Current webview package com.google.android.webview and version 97.0.4692.98
01-22 13:06:11.107  9572  9613 D SensorWorker: Updating all Sensors.
01-22 13:06:11.110  9572  9637 I WM-Processor: Moving WorkSpec (63556e60-855e-4a4f-8576-a4ef7b60e772) to the foreground
01-22 13:06:11.119  9572  9613 W SensorReceiver: Device not registered, skipping sensor update/registration

This is bypassing any proxy or anything, hitting the local IP where HA runs with the Docker host network adapter.

The “Unable to register device” line logged above seems to come from this line.

The device registration attempt seems to fail, but the login works. Using the computer I can see my user has a new token from the Pixel phone:

Refresh token for Home Assistant Android - Home Assistant
Created 40 seconds ago
Last used 40 seconds ago from 192.168.1.226

At this stage I wanted to try the register device API by myself so started to look for the documentation. I found the “mobile_app” resource does not exist. Kept reading till I found this snippet

Home Assistant has a mobile_app component that allows applications to register themselves and interact with the instance. This is a generic component to handle most common mobile application tasks. This component is extendable with custom interactions if your app needs more types of interactions than are offered by this component.

Added mobile_app: as a single line to HA configuration file, retried the flow and got connected. The application does not ask for the instance URL anymore, and the mobile integration appeared in HA.

Solution: ensure you have enabled the mobile_app integration in your configuration file.

1 Like

ah that makes sense, BTW this requirement is listed in our getting started section. Will make sure to add it to the troubleshooting steps too.

I find odd that without mobile_app the UI works, but not the device register part.

If having mobile_app is a requirement for the App to work, and if the /api/mobile_app/ endpoints depend on having mobile_app enabled, I think it would make sense to catch the 404s ocurring during the device registration and logging something like “/mobile_app/ resource not found, ensure mobile_app is enabled in your instance”

Maybe the App should be clearer on this aspect too, during the onboarding process it could let the user know that “HA features can be used, but the device failed to be registered”, rather than moving forward silently.

@freedog96150 , take a look in your config file, ensure default_config or mobile_app are set in your configuration file and retry.

Thanks @dshokouhi for your patience and support!

Hi folks, sorry to bring this back to life, but I’ve a similar issue. I just upgraded my phone and now I have to keep entering the connection details. On top of that, there’s no mobile app menu, and under system, all I’m seeing is restart. The phone is not showing on the mobile app integration.

I do have mobile_app: in my config, so not sure what’s happening.

Do you have a proxy or anything? If so try to bypass it as it sounds like the external bus and the callbacks are not working. You may need to setup LogCat Reader to get the logs if you continue having issues.

Nothing at all. Literally I access via nabu casa. The only thing that’s changed in the last few days is I installed the app on my new phone.

No other system changes made.

I just installed the app for them first time, it’s not remembering my login or server address.
Using Android 11.
When I login I don’t see any app menus, just my home assistant dashboard.

@Sidioussam I tried all suggestions here and nothing seemed to work. I will mention that while I had the current version of the app installed, my HA version was hopelessly behind as the number of breaking changes seemed a bit daunting. I wound up uninstalling the mobile app in frustration. As previously mentioned by myself and a few others on this thread, the only real difference between a working and broken app seemed to be the new phone.

Fast forward and I now have it all working. So what happened? Hard to say but I did wind up updating my HA from the 0.94.x version I was running to a more current 2022.4.6 (I am already behind on updates again). After spending hours fixing all the breaks, redoing all the zwave devices, and deleting tons of unused entities and general config file cleanup, I decided to re-install the Android mobile app and it worked. It just worked as expected and has been working since.

My takeaways, but not necessarily solutions, on this issue are as follows:

  • All versions of HA and the app should be on the most recent versions.
  • Entity cleanup. I used a plugin from HACS called Watchman to assist. I did completely delete any old entities for my old phone while at it as well. When done, there was not a stray entity left in my config.

I wish I would have been more methodical with my process. But hoping that responding back that my setup is now working and all it took was a bunch of upgrading and general cleanup helps others get back up and running properly.