Hey @dshokouhi,
I followed those steps quite a few times already. Will do that again, leaving a note of the state between every step:
- 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.
- 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.
- 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.
- Restart Home Assistant.
Did it many times during the testing flow.
- 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