Closed XalaTheShepard closed 2 months ago
Hey there @kane610, mind taking a look at this issue as it has been labeled with an integration (unifi
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
unifi documentation unifi source (message by IssueLinks)
I am seeing the same failed to connect issue in the June release of HAOS/HA. My Unifi controller is remote, but I'm giving the correct credentials as verified by logging into the same hostname on my controller's web GUI.
This is my first time installing it. I've never tried to install the Unifi Integration previously.
Also, I recommend some documentation or a greyed out text in the host field showing example.com because its not clear if a leading https:// is needed in the hostname field.
Thanks for posting this OP.
I noticed that I forgot to mention that I am running the UniFi controller as a HA Add-on
I also meet this problem even I have create a local authentication account. Any tips to resolve this problem?
In my case, the issue has been solved. I have logged in into both the Unifi controller and HA using the local IP address. Then I have created a local user in the Unifi controller. I deleted the Unifi Network integration in the local HA and afterwards added it again with the credentials of the local administrator account of the Unifi controller. Now I have both 1 local Unifi administrator and 1 remote Unifi administrator, of which the latter has to use the 2FA.
Do you see any errors in the logs?
@BlackRockCity and @leeaash , this is a question for your issues as for me the issue has been resolved
I've been hitting the same issue recently - however - it seems like my integration got in a bad state and was hitting the login endpoint on the controller too much. From the integration logs, the controller is now returning a 429 Too Many Requests
error:
2024-06-21 16:35:17.775 DEBUG (MainThread) [aiounifi.interfaces.connectivity] data (from https://192.168.4.1:443) b'<!doctype html><html lang="en"><head><meta charset="utf-8"><link rel="icon" href="/favicon.ico?v3" sizes="any"><link rel="icon" href="/favicon.svg?v3" type="image/svg+xml"><link rel="apple-touch-icon" href="/apple-touch-icon.png?v3"><title>UniFi OS</title><meta name="viewport" content="width=device-width,initial-scale=1"><script>window.UNIFI_OS_MANIFEST = {"model":{"id":"UDW","shortName":"UDW","longName":"UniFi Dream Wall"},"images":{"small":"/assets/images/small.png?udw-2.0.0","medium":"/assets/images/medium.png?udw-2.0.0","large":"/assets/images/large.png?udw-2.0.0","huge":"/assets/images/huge.png?udw-2.0.0"}}</script><script defer="defer" src="/main.1f13cbe8ee4a4f1a0848.js"></script><link href="/main.0e9197a3.css" rel="stylesheet"></head><body><div id="root"></div></body></html>'
2024-06-21 16:35:17.775 DEBUG (MainThread) [aiounifi.interfaces.connectivity] Talking to UniFi OS device: True
2024-06-21 16:35:17.775 DEBUG (MainThread) [aiounifi.interfaces.connectivity] sending (to https://192.168.4.1:443/api/auth/login) post, {'username': 'viewonly', 'password': 'OMITTED', 'rememberMe': True}, {}
2024-06-21 16:35:17.792 DEBUG (MainThread) [aiounifi.interfaces.connectivity] received (from https://192.168.4.1:443/api/auth/login) 429 application/json <ClientResponse(https://192.168.4.1:443/api/auth/login) [429 Too Many Requests]>
<CIMultiDictProxy('Server': 'nginx', 'Date': 'Fri, 21 Jun 2024 20:35:17 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '113', 'Connection': 'keep-alive', 'X-Response-Time': '12ms', 'Access-Control-Allow-Credentials': 'false', 'Referrer-Policy': 'no-referrer', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Content-Type-Options': 'nosniff', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block')>
2024-06-21 16:35:17.792 DEBUG (MainThread) [aiounifi.interfaces.connectivity] data (from https://192.168.4.1:443/api/auth/login) b'{"code":"AUTHENTICATION_FAILED_LIMIT_REACHED","message":"You\'ve reached the login attempt limit","level":"debug"}'
2024-06-21 16:35:17.792 ERROR (MainThread) [homeassistant.components.unifi] Error connecting to the UniFi Network at 192.168.4.1: Call https://192.168.4.1:443/api/auth/login received 429: b'{"code":"AUTHENTICATION_FAILED_LIMIT_REACHED","message":"You\'ve reached the login attempt limit","level":"debug"}'
2024-06-21 16:35:18.257 ERROR (MainThread) [homeassistant.components.unifiprotect.data] Auth error while updating
Traceback (most recent call last):
File "/nix/store/sq3by8r3524slnqjm5cj09abg3q455zx-homeassistant-2024.6.3/lib/python3.12/site-packages/homeassistant/components/unifiprotect/data.py", line 133, in async_refresh
updates = await self.api.update(force=force)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/v1x8g45h8ywwifv4jq4v5pdzh0svrl2y-python3.12-uiprotect-1.7.2/lib/python3.12/site-packages/uiprotect/api.py", line 799, in update
self._bootstrap = await self.get_bootstrap()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/v1x8g45h8ywwifv4jq4v5pdzh0svrl2y-python3.12-uiprotect-1.7.2/lib/python3.12/site-packages/uiprotect/api.py", line 1127, in get_bootstrap
data = await self.api_request_obj("bootstrap")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/v1x8g45h8ywwifv4jq4v5pdzh0svrl2y-python3.12-uiprotect-1.7.2/lib/python3.12/site-packages/uiprotect/api.py", line 427, in api_request_obj
data = await self.api_request(
^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/v1x8g45h8ywwifv4jq4v5pdzh0svrl2y-python3.12-uiprotect-1.7.2/lib/python3.12/site-packages/uiprotect/api.py", line 406, in api_request
data = await self.api_request_raw(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/v1x8g45h8ywwifv4jq4v5pdzh0svrl2y-python3.12-uiprotect-1.7.2/lib/python3.12/site-packages/uiprotect/api.py", line 381, in api_request_raw
raise NotAuthorized(msg % (url, response.status, reason))
uiprotect.exceptions.NotAuthorized: Request failed: /proxy/protect/api/bootstrap - Status: 401 - Reason: {'code': 401, 'message': 'Unauthorized'}
I suspect something happened to my integration and got stuck in a tight auth loop. This manifests in the UI as Failed to connect
Not sure if this is what others are hitting but check your logs. We could consider doing some backoff in the integration if we see a 429.
I'm having this issue. I'm trying to connect using the local IP address of the UDM and port 443. I'm able to log into unifi on a browser using that IP and the local user account I created. I tried deleting and creating a new local user account on Unifi and still I get the same issue.
Logs only show one line: "Error connecting to the UniFi Network at " (my local IP)
Can you enable/download the diagnostic logs, restart the integration and post the resulting logs here? (Be sure to remove your password in the logs!)
I can't get the integration to actually enable to the point that I can access the page and download the diagnostic logs. Basically, when I search for Protect and add the integration, it prompts me to enter host, username, password etc. but the submit form fails, and the integration never gets added.
Relevant: I'm using Protect application 4.0.33. I was in Early Access but I changed back to stable. I believe this is the official release
I can't get the integration to actually enable to the point that I can access the page and download the diagnostic logs.
Same here!
I can't get the integration to actually enable to the point that I can access the page and download the diagnostic logs. Basically, when I search for Protect and add the integration, it prompts me to enter host, username, password etc. but the submit form fails, and the integration never gets added.
Relevant: I'm using Protect application 4.0.33. I was in Early Access but I changed back to stable. I believe this is the official release
Please open a separate issue for protect
I've been hitting the same issue recently - however - it seems like my integration got in a bad state and was hitting the login endpoint on the controller too much. From the integration logs, the controller is now returning a
429 Too Many Requests
error:2024-06-21 16:35:17.775 DEBUG (MainThread) [aiounifi.interfaces.connectivity] data (from https://192.168.4.1:443) b'<!doctype html><html lang="en"><head><meta charset="utf-8"><link rel="icon" href="/favicon.ico?v3" sizes="any"><link rel="icon" href="/favicon.svg?v3" type="image/svg+xml"><link rel="apple-touch-icon" href="/apple-touch-icon.png?v3"><title>UniFi OS</title><meta name="viewport" content="width=device-width,initial-scale=1"><script>window.UNIFI_OS_MANIFEST = {"model":{"id":"UDW","shortName":"UDW","longName":"UniFi Dream Wall"},"images":{"small":"/assets/images/small.png?udw-2.0.0","medium":"/assets/images/medium.png?udw-2.0.0","large":"/assets/images/large.png?udw-2.0.0","huge":"/assets/images/huge.png?udw-2.0.0"}}</script><script defer="defer" src="/main.1f13cbe8ee4a4f1a0848.js"></script><link href="/main.0e9197a3.css" rel="stylesheet"></head><body><div id="root"></div></body></html>' 2024-06-21 16:35:17.775 DEBUG (MainThread) [aiounifi.interfaces.connectivity] Talking to UniFi OS device: True 2024-06-21 16:35:17.775 DEBUG (MainThread) [aiounifi.interfaces.connectivity] sending (to https://192.168.4.1:443/api/auth/login) post, {'username': 'viewonly', 'password': 'OMITTED', 'rememberMe': True}, {} 2024-06-21 16:35:17.792 DEBUG (MainThread) [aiounifi.interfaces.connectivity] received (from https://192.168.4.1:443/api/auth/login) 429 application/json <ClientResponse(https://192.168.4.1:443/api/auth/login) [429 Too Many Requests]> <CIMultiDictProxy('Server': 'nginx', 'Date': 'Fri, 21 Jun 2024 20:35:17 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '113', 'Connection': 'keep-alive', 'X-Response-Time': '12ms', 'Access-Control-Allow-Credentials': 'false', 'Referrer-Policy': 'no-referrer', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Content-Type-Options': 'nosniff', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block')> 2024-06-21 16:35:17.792 DEBUG (MainThread) [aiounifi.interfaces.connectivity] data (from https://192.168.4.1:443/api/auth/login) b'{"code":"AUTHENTICATION_FAILED_LIMIT_REACHED","message":"You\'ve reached the login attempt limit","level":"debug"}' 2024-06-21 16:35:17.792 ERROR (MainThread) [homeassistant.components.unifi] Error connecting to the UniFi Network at 192.168.4.1: Call https://192.168.4.1:443/api/auth/login received 429: b'{"code":"AUTHENTICATION_FAILED_LIMIT_REACHED","message":"You\'ve reached the login attempt limit","level":"debug"}' 2024-06-21 16:35:18.257 ERROR (MainThread) [homeassistant.components.unifiprotect.data] Auth error while updating Traceback (most recent call last): File "/nix/store/sq3by8r3524slnqjm5cj09abg3q455zx-homeassistant-2024.6.3/lib/python3.12/site-packages/homeassistant/components/unifiprotect/data.py", line 133, in async_refresh updates = await self.api.update(force=force) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/v1x8g45h8ywwifv4jq4v5pdzh0svrl2y-python3.12-uiprotect-1.7.2/lib/python3.12/site-packages/uiprotect/api.py", line 799, in update self._bootstrap = await self.get_bootstrap() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/v1x8g45h8ywwifv4jq4v5pdzh0svrl2y-python3.12-uiprotect-1.7.2/lib/python3.12/site-packages/uiprotect/api.py", line 1127, in get_bootstrap data = await self.api_request_obj("bootstrap") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/v1x8g45h8ywwifv4jq4v5pdzh0svrl2y-python3.12-uiprotect-1.7.2/lib/python3.12/site-packages/uiprotect/api.py", line 427, in api_request_obj data = await self.api_request( ^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/v1x8g45h8ywwifv4jq4v5pdzh0svrl2y-python3.12-uiprotect-1.7.2/lib/python3.12/site-packages/uiprotect/api.py", line 406, in api_request data = await self.api_request_raw( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/v1x8g45h8ywwifv4jq4v5pdzh0svrl2y-python3.12-uiprotect-1.7.2/lib/python3.12/site-packages/uiprotect/api.py", line 381, in api_request_raw raise NotAuthorized(msg % (url, response.status, reason)) uiprotect.exceptions.NotAuthorized: Request failed: /proxy/protect/api/bootstrap - Status: 401 - Reason: {'code': 401, 'message': 'Unauthorized'}
I suspect something happened to my integration and got stuck in a tight auth loop. This manifests in the UI as
Failed to connect
Not sure if this is what others are hitting but check your logs. We could consider doing some backoff in the integration if we see a 429.
Have you gotten it back to running?
I had the same issue, the integration was working, then it wasn't I was complaining abut too many failed authentication attempts, however credentials had not changed, I removed the UDM controller from the integration and tried to re-add it, this failed to get past the add box with failed to connect. I removed the user from the local controller and waited a few hours, then re-added it all back and it worked.
For the 429 - yes. Try disabling the integration and restarting the controller. Then re-enable the integration worked for me.
After updating to HA 2024.7 (and enabling the MFA for Unifi some weeks ago) I get a similar error. I added a local admin and also tried disabling the integration and restarting the Unifi controller.
In HA I geht the error "Unknown error occurred". This is what I found in the logs:
2024-07-12 10:28:15.507 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
return await func(self, request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
return await super().post(request, flow_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
return await method(view, request, data, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
result = await self._flow_mgr.async_configure(flow_id, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in async_configure
result = await self._async_configure(flow_id, user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 415, in _async_configure
result = await self._async_handle_step(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 518, in _async_handle_step
result: _FlowResultT = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/unifi/config_flow.py", line 125, in async_step_user
return await self.async_step_site(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/unifi/config_flow.py", line 171, in async_step_site
hub = config_entry.runtime_data
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ConfigEntry' object has no attribute 'runtime_data'
I did not delete and reconfigure the Unifi integration but changed the username and password to the new local admin instead.
After updating to HA 2024.7 (and enabling the MFA for Unifi some weeks ago) I get a similar error. I added a local admin and also tried disabling the integration and restarting the Unifi controller.
In HA I geht the error "Unknown error occurred". This is what I found in the logs:
2024-07-12 10:28:15.507 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle result = await handler(request, **request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin return await func(self, request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post return await super().post(request, flow_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper return await method(view, request, data, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post result = await self._flow_mgr.async_configure(flow_id, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in async_configure result = await self._async_configure(flow_id, user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 415, in _async_configure result = await self._async_handle_step( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 518, in _async_handle_step result: _FlowResultT = await getattr(flow, method)(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/unifi/config_flow.py", line 125, in async_step_user return await self.async_step_site( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/unifi/config_flow.py", line 171, in async_step_site hub = config_entry.runtime_data ^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ConfigEntry' object has no attribute 'runtime_data'
I did not delete and reconfigure the Unifi integration but changed the username and password to the new local admin instead.
I have hopefully fixed that issue. And should be out with the next point release
Just tried again with the latest release and it works now. Thank you!
Runtime_issue has been fixed. Closing this issue.
Continue in this thread https://github.com/home-assistant/core/issues/122438 for 401/429 issues
The problem
Dear,
In July 2024, Unifi will require 2FA exept for local accounts. I have created a local account with Administrator rights in my Unifi controller (Remote access disabled). When trying to connect the local account to the Unifi integration, I always get the message "Failed to connect". Please find enclosed the images with the setup of the account and the error. Could you please assist me with this issue?
Many thanks.
Kind regards,
Robin
What version of Home Assistant Core has the issue?
2024.6.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
UniFi Network
Link to integration documentation on our website
https://www.home-assistant.io/integrations/unifi/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response