Invalid login notification keeps coming up after placing Android state widget

Since I placed a state entity widget on my Android homescreen, I keep getting notifications in home assistant about invalid login attempts.

The ip address logged is the local ip of my ISP modem/router/gateway.

Log:

Blockquote
Logger: homeassistant.components.http.ban
Source: components/http/ban.py:129
Integration: HTTP (documentation, issues)
First occurred: 8 December 2023 at 19:02:22 (3 occurrences)
Last logged: 14:15:18
Login attempt or request with invalid authentication from 192.168.2.254 (192.168.2.254). Requested URL: ‘/api/websocket’. (Home Assistant/2023.10.2-11484 (Android 13; Mi MIX 2S))
Login attempt or request with invalid authentication from 192.168.2.254 (192.168.2.254). Requested URL: ‘/api/states/sensor.living_room_temperature’. (Home Assistant/2023.10.2-11484 (Android 13; Mi MIX 2S))

The widget does work though. Even though I catch it having a red mark on it from time to time. Which I assume means there is no connection. After opening and closing the HA app, the red mark goes away.

Any idea why it fails to login 2-3 times per day?

Thanks in advance!

I have the exact same issue. Seems to happen when the device reconnects to the home Wifi, therefore reloading information of the state widgets. It seems like the widget tries to connect to the Home Assistant server, without success. Opening the HA app then solves the issue. But it happens again and again and again.

My configuration is using an external URL.

Logger: homeassistant.components.http.ban
Source: components/http/ban.py:129
Integration: HTTP ([documentation], [issues])
First occurred: December 27, 2023 at 7:09:00 PM (19 occurrences)
Last logged: December 27, 2023 at 10:11:22 PM

  • Login attempt or request with invalid authentication from 10.XXX.X.XXX. Requested URL: ‘/api/states/xxx’. (Home Assistant/2023.12.4-11898 (Android 9; SM-J330FN))
    etc.

I have the same issue too. It happens about once a day, but with different intervals. It seems to be related to the widget on my homescreen. The warnings do not occur if I remove the widget.

I enabled debug logging on the component homeassistant.components.http and captured the following logs around the event.

2024-01-28 06:48:50.642 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/websocket to <ip> (auth: False)
2024-01-28 06:48:50.707 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from <hostname> (<ip>). Requested URL: '/api/websocket'. (Home Assistant/2023.12.4-11898 (Android 14; <device>))
2024-01-28 06:49:00.929 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/token to <ip> (auth: False)
2024-01-28 06:49:00.978 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/websocket to <ip> (auth: False)
2024-01-28 06:49:01.126 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [140639218829632] Initialized trigger

what does the companion app errors say?

It gives a notification. Unfortunatly I just cleared them. The text is along the lines of the log message

Login attempt or request with invalid authentication from <hostname> (<ip>)

The next time it happens I’ll post the exact message. Additionally I have enabeled debug logging for homeassistant.components.websocket_api. Maybe that provides some additional information as well.

companion app errors do not do that.

Settings > Companion App > Troubleshooting > show and share logs

Ah, found them. The current logs only go back an hour or so. When the error happens again I’ll try to gather the relevant logs from the app as well.

I had the notifications recurring every day. But since 4 days they stopped. The authentication error is also not present anymore in the logs.

Not sure what changed. I did upgrade HA and the app got an update. But those do not align with when the notifications stopped.

So unfortunately no additional logs at this moment.

I am still having the notification errors. I guess you are asking for the guilty Android smartphone generating these failed connection attempt? I can try and get some logs next weeks from the guilty phone.

The errors have been happening intermittently (see attached image) for me and I was not able to capture log data from the app until now. I have logging for the invalid login notification from both the app as HA itself. I did remove some PII from the logs.

Daily count of invalid login errors since Jan 21th:

HA connection debug logging

2024-02-23 17:57:29.105	2024-02-23 16:57:29.104 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 2a02:a46f:c24e:1:<REMOVED> (auth: False)
2024-02-23 17:57:29.105	2024-02-23 16:57:29.104 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846149568] from 2a02:a46f:c24e:1:<REMOVED> (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B)): Connected from 2a02:a46f:c24e:1:<REMOVED>
2024-02-23 17:57:29.157	2024-02-23 16:57:29.156 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846149568] from 2a02:a46f:c24e:1:<REMOVED> (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B)): Received {'type': 'auth', 'access_token': '<TOKEN_1>'}
2024-02-23 17:57:29.195	2024-02-23 16:57:29.193 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from 2a02-a46f-c24e-1-<REMOVED>.fixed6.kpn.net (2a02:a46f:c24e:1:<REMOVED>). Requested URL: '/api/websocket'. (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B))
2024-02-23 17:57:29.195	2024-02-23 16:57:29.194 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846149568] from 2a02:a46f:c24e:1:<REMOVED> (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B)): Connection closed by client: 
2024-02-23 17:57:29.641	2024-02-23 16:57:29.640 DEBUG (MainThread) [homeassistant.components.http.view] Serving /auth/token to 2a02:a46f:c24e:1:<REMOVED> (auth: False)
2024-02-23 17:57:39.198	2024-02-23 16:57:39.197 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846149568] from 2a02:a46f:c24e:1:<REMOVED> (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B)): Disconnected
2024-02-23 17:57:39.408	2024-02-23 16:57:39.406 DEBUG (MainThread) [homeassistant.components.http.view] Serving /api/websocket to 2a02:a46f:c24e:1:<REMOVED> (auth: False)
2024-02-23 17:57:39.409	2024-02-23 16:57:39.408 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846138432] from 2a02:a46f:c24e:1:<REMOVED> (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B)): Connected from 2a02:a46f:c24e:1:<REMOVED>
2024-02-23 17:57:39.456	2024-02-23 16:57:39.454 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846138432] from 2a02:a46f:c24e:1:<REMOVED> (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B)): Received {'type': 'auth', 'access_token': '<TOKEN_2>'}
2024-02-23 17:57:39.457	2024-02-23 16:57:39.456 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846138432] Auth OK
2024-02-23 17:57:39.525	2024-02-23 16:57:39.524 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846138432] <NAME> from 2a02:a46f:c24e:1:<REMOVED> (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B)): Received {'type': 'supported_features', 'id': 106, 'features': {'coalesce_messages': 1}}
2024-02-23 17:57:39.526	2024-02-23 16:57:39.524 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846138432] <NAME> from 2a02:a46f:c24e:1:<REMOVED> (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B)): Sending b'{"id":106,"type":"result","success":true,"result":null}'
2024-02-23 17:57:39.550	2024-02-23 16:57:39.548 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846138432] <NAME> from 2a02:a46f:c24e:1:<REMOVED> (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B)): Received {'type': 'subscribe_trigger', 'trigger': {'platform': 'state', 'entity_id': ['light.lamp_werkkamer']}, 'id': 107}
2024-02-23 17:57:39.551	2024-02-23 16:57:39.549 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846138432] Initialized trigger
2024-02-23 17:57:39.551	2024-02-23 16:57:39.550 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846138432] <NAME> from 2a02:a46f:c24e:1:<REMOVED> (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B)): Sending b'{"id":107,"type":"result","success":true,"result":null}'
2024-02-23 17:57:39.594	2024-02-23 16:57:39.592 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846138432] <NAME> from 2a02:a46f:c24e:1:<REMOVED> (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B)): Received {'type': 'subscribe_trigger', 'trigger': {'platform': 'state', 'entity_id': ['light.lamp_werkkamer']}, 'id': 108}
2024-02-23 17:57:39.595	2024-02-23 16:57:39.593 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846138432] Initialized trigger
2024-02-23 17:57:39.595	2024-02-23 16:57:39.593 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [139911846138432] <NAME> from 2a02:a46f:c24e:1:<REMOVED> (Home Assistant/2024.1.5-12102 (Android 14; SM-G991B)): Sending b'{"id":108,"type":"result","success":true,"result":null}'

HA Companion App logging
→ Had to put them on pastebin due to the size:

@dshokouhi is this type of error that you meant? I do have the logging for a second instance where it happened as well, if that helps.

Edit: the entity light.lamp_werkkamer is the one for which I have a widget on my home screen.