home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.9k stars 30.12k forks source link

Unifi Networks plugin will not connect following update to 2022.7.0 - 401 for valid credentials #74602

Closed JoshuaRedmond closed 2 years ago

JoshuaRedmond commented 2 years ago

The problem

Potentially related to #74547 but different error in logs.

Following update to 2022.7.0 I can see the below error in the logs. Not fixed by temporarily disabling and re-enabling the integration. Upon removing the integration, I get the following error when trying to add it again, and the same error in the logs. I've confirmed that the Unifi credentials are correct and allow me to log into the console without issue.

Screenshot 2022-07-07 at 11 11 59

What version of Home Assistant Core has the issue?

2022.7.0

What was the last working version of Home Assistant Core?

2022.6.6

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Unifi Network

Link to integration documentation on our website

https://www.home-assistant.io/integrations/unifi

Diagnostics information

Unable to provide as integration no longer installed

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-07-07 11:10:56 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiounifi/controller.py", line 287, in request
    return await self._request(method, url, json)
  File "/usr/local/lib/python3.10/site-packages/aiounifi/controller.py", line 323, in _request
    raise LoginRequired(f"Call {url} received 401 Unauthorized")
aiounifi.errors.LoginRequired: Call https://192.168.0.1:443/proxy/network/api/self/sites received 401 Unauthorized
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 94, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 79, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 177, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 109, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 277, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 359, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/unifi/config_flow.py", line 112, in async_step_user
    sites = await controller.sites()
  File "/usr/local/lib/python3.10/site-packages/aiounifi/controller.py", line 148, in sites
    sites = await self.request("get", url=url)
  File "/usr/local/lib/python3.10/site-packages/aiounifi/controller.py", line 295, in request
    return await self._request(method, url, json)
  File "/usr/local/lib/python3.10/site-packages/aiounifi/controller.py", line 323, in _request
    raise LoginRequired(f"Call {url} received 401 Unauthorized")
aiounifi.errors.LoginRequired: Call https://192.168.0.1:443/proxy/network/api/self/sites received 401 Unauthorized

Additional information

No response

probot-home-assistant[bot] commented 2 years 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)

JoshuaRedmond commented 2 years ago

Unifi console information: UDM Pro UniFi OS Version 1.11.4 Unifi Network Version 7.1.61

Kane610 commented 2 years ago

Start by upgrading to latest stable

nightfever77 commented 2 years ago

Same here: UDM UniFi OS 1.12.22 Network 7.1.6

Kane610 commented 2 years ago

@stonith what do you think

Kane610 commented 2 years ago

I would like some integration debug logs that show what data is sent back from controller

kungfuice commented 2 years ago

Seeing the same issue and was going to raise a ticket for it this morning. Here's what I have from the logs with DEBUG turned on:

2022-07-06 16:29:07 DEBUG (MainThread) [aiounifi.controller] 200 text/html <ClientResponse(https://redacted.fu.com:443) [200 OK]> <CIMultiDictProxy('Vary': 'Origin', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': '450cfc95-2314-48d4-b4d3-da42e12b56df', 'Content-Type': 'text/html; charset=utf-8', 'Content-Length': '450', 'X-Response-Time': '3ms', 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjc3JmVG9rZW4iOiI0NTBjZmM5NS0yMzE0LTQ4ZDQtYjRkMy1kYTQyZTEyYjU2ZGYiLCJpYXQiOjE2NTcxMzkzNDcsImV4cCI6MTY1NzE0Mjk0N30.3UymlcVR2ypMPYt7CB2U1l8pOhg8I17i1ZDTv6To_Us; path=/; samesite=none; secure; httponly', 'Date': 'Wed, 06 Jul 2022 20:29:07 GMT', 'Connection': 'keep-alive')> 2022-07-06 16:29:07 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/api/auth/login 2022-07-06 16:29:07 DEBUG (MainThread) [aiounifi.controller] 403 application/json <ClientResponse(https://redacted.fu.com:443/api/auth/login) [403 Forbidden]> <CIMultiDictProxy('Vary': 'Origin', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'Content-Type': 'application/json; charset=utf-8', 'X-Response-Time': '3ms', 'Content-Length': '32', 'Date': 'Wed, 06 Jul 2022 20:29:07 GMT', 'Connection': 'keep-alive')> 2022-07-06 16:29:07 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/proxy/network/api/self/sites 2022-07-06 16:29:07 DEBUG (MainThread) [aiounifi.controller] 401 text/plain <ClientResponse(https://redacted.fu.com:443/proxy/network/api/self/sites) [401 Unauthorized]> <CIMultiDictProxy('Vary': 'Origin', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': '450cfc95-2314-48d4-b4d3-da42e12b56df', 'X-Response-Time': '3ms', 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjc3JmVG9rZW4iOiI0NTBjZmM5NS0yMzE0LTQ4ZDQtYjRkMy1kYTQyZTEyYjU2ZGYiLCJpYXQiOjE2NTcxMzkzNDcsImV4cCI6MTY1NzE0Mjk0N30.3UymlcVR2ypMPYt7CB2U1l8pOhg8I17i1ZDTv6To_Us; path=/; samesite=none; secure; httponly', 'Content-Type': 'text/plain; charset=utf-8', 'Content-Length': '12', 'Date': 'Wed, 06 Jul 2022 20:29:07 GMT', 'Connection': 'keep-alive')> 2022-07-06 16:29:07 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/api/auth/login 2022-07-06 16:29:07 DEBUG (MainThread) [aiounifi.controller] 403 application/json <ClientResponse(https://redacted.fu.com:443/api/auth/login) [403 Forbidden]> <CIMultiDictProxy('Vary': 'Origin', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'Content-Type': 'application/json; charset=utf-8', 'X-Response-Time': '0ms', 'Content-Length': '32', 'Date': 'Wed, 06 Jul 2022 20:29:07 GMT', 'Connection': 'keep-alive')> 2022-07-06 16:29:07 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/proxy/network/api/self/sites 2022-07-06 16:29:07 DEBUG (MainThread) [aiounifi.controller] 401 text/plain <ClientResponse(https://redacted.fu.com:443/proxy/network/api/self/sites) [401 Unauthorized]> <CIMultiDictProxy('Vary': 'Origin', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': '450cfc95-2314-48d4-b4d3-da42e12b56df', 'X-Response-Time': '3ms', 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjc3JmVG9rZW4iOiI0NTBjZmM5NS0yMzE0LTQ4ZDQtYjRkMy1kYTQyZTEyYjU2ZGYiLCJpYXQiOjE2NTcxMzkzNDcsImV4cCI6MTY1NzE0Mjk0N30.3UymlcVR2ypMPYt7CB2U1l8pOhg8I17i1ZDTv6To_Us; path=/; samesite=none; secure; httponly', 'Content-Type': 'text/plain; charset=utf-8', 'Content-Length': '12', 'Date': 'Wed, 06 Jul 2022 20:29:07 GMT', 'Connection': 'keep-alive')>

UDM is the device where the controller is running. UnifiOS: 1.11.4 Network: 7.1.66

Wedee98 commented 2 years ago

Same issue after upgrade....

Home Assistant: 2022.7.0 Supervisor: 2022.07.0 Operating System: 8.2 Frontend: 20220706.0 - latest

UnifiOS: 1.12.22 Network: 7.1.66

Saw it was failed, disabled -> enabled no change Deleted and tried to setup again -> Unknown Error Tried recreating local user on UDMPro - No change

Kane610 commented 2 years ago

@kungfuice

Seeing the same issue and was going to raise a ticket for it this morning. Here's what I have from the logs with DEBUG turned on:

UDM is the device where the controller is running. UnifiOS: 1.11.4 Network: 7.1.66

Thanks! Please go to the latest releases so we can make sure there are as few differences as possible

From your logs I can see that you get a 403 error

16:29:07 DEBUG (MainThread) [aiounifi.controller] 403 application/json

How are you hosting your UDM as you have a full url (https://redacted.fu.com:443)

Interesting that in your logs there is a cookie 'Set-Cookie' with a token already on the first call, where as on my logs its empty

Yours 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjc3JmVG9rZW4iOiI0NTBjZmM5NS0yMzE0LTQ4ZDQtYjRkMy1kYTQyZTEyYjU2ZGYiLCJpYXQiOjE2NTcxMzkzNDcsImV4cCI6MTY1NzE0Mjk0N30.3UymlcVR2ypMPYt7CB2U1l8pOhg8I17i1ZDTv6To_Us; Mine 'Set-Cookie': 'TOKEN=;

stonith commented 2 years ago

I can't reproduce on my setup with UniFi OS 1.12.22, Network 7.1.66. I was only able to reproduce the 403 error when I typed my password incorrectly.

Kane610 commented 2 years ago

@stonith

I can't reproduce on my setup with UniFi OS 1.12.22, Network 7.1.66. I was only able to reproduce the 403 error when I typed my password incorrectly.

Can you check your debug logs if you (like me) get the empty cookie token on the first request (check_unifi_os)

stonith commented 2 years ago

On the initial request to https://{udm}/ yes it's empty cookie token: Set-Cookie: TOKEN=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; samesite=none; secure; httponly

Kane610 commented 2 years ago

I also noticed the time stamp in your post now, I have the same issue in mine, 1970... Seems like there is a bug in UniFi.

I want to see if the log output changes for @kungfuice after upgrading. I also wonder if he runs UDM or UDM pro if there is a slight firmware difference between devices.

kungfuice commented 2 years ago

After updating to 1.12.22 on the UDM Pro seems to have fixed the issue, the logs now show the login going through properly

2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] 200 text/html <ClientResponse(https://redacted.fu.com:443) [200 OK]> <CIMultiDictProxy('Vary': 'Origin', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': '91c3a030-6c3a-43e8-bff0-8597616ce325', 'Content-Type': 'text/html; charset=utf-8', 'Content-Length': '450', 'X-Response-Time': '3ms', 'Set-Cookie': 'TOKEN=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; samesite=none; secure; httponly', 'Date': 'Thu, 07 Jul 2022 20:31:07 GMT', 'Connection': 'keep-alive')> 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/api/auth/login 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] 200 application/json <ClientResponse(https://redacted.fu.com:443/api/auth/login) [200 OK]> <CIMultiDictProxy('Vary': 'Origin', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': 'b33e7a47-b760-4f18-853a-c19b4e765574', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '6267', 'X-Response-Time': '193ms', 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2ZTA1MTNkZi0wMmNjLTRkZWItOGVjOC0xNWFkOTI5NWVmNzEiLCJjc3JmVG9rZW4iOiJiMzNlN2E0Ny1iNzYwLTRmMTgtODUzYS1jMTliNGU3NjU1NzQiLCJpYXQiOjE2NTcyMjU4NjcsImV4cCI6MTY1NzIyOTQ2NywianRpIjoiYzJkYWZjNjQtNDk1My00ZDQzLTg3YTctYjgwNzAzYzk0NzQ0In0.ppKXCoaDTUkcgVrix3xtv-amCU7xtEhJ817I1DdDEeA; path=/; samesite=none; secure; httponly', 'Date': 'Thu, 07 Jul 2022 20:31:07 GMT', 'Connection': 'keep-alive')> 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/proxy/network/api/self/sites 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] 200 application/json <ClientResponse(https://redacted.fu.com:443/proxy/network/api/self/sites) [200 OK]> <CIMultiDictProxy('Vary': 'Origin', 'X-DNS-Prefetch-Control': 'off', 'x-frame-options': 'DENY', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': 'b33e7a47-b760-4f18-853a-c19b4e765574', 'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '323', 'Date': 'Thu, 07 Jul 2022 20:31:07 GMT', 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2ZTA1MTNkZi0wMmNjLTRkZWItOGVjOC0xNWFkOTI5NWVmNzEiLCJjc3JmVG9rZW4iOiJiMzNlN2E0Ny1iNzYwLTRmMTgtODUzYS1jMTliNGU3NjU1NzQiLCJqdGkiOiJjMmRhZmM2NC00OTUzLTRkNDMtODdhNy1iODA3MDNjOTQ3NDQiLCJwYXNzd29yZFJldmlzaW9uIjoxNjU3MTM4ODU3LCJpYXQiOjE2NTcyMjU4NjcsImV4cCI6MTY1NzIyOTQ2N30.xNnn8vU1xTAcOBUYiaCAEzgwI6nmXN7VfnrAqtOiJ0o; path=/; samesite=none; secure; httponly', 'Connection': 'keep-alive')> 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] [{'_id': '5d01a14f7c90af001a10fd9d', 'anonymous_id': 'ce3dcae5-dcaa-43d1-9a46-5dd79204e2fc', 'attr_hidden_id': 'default', 'attr_no_delete': True, 'desc': 'Default', 'location_accuracy': 150.0, 'location_lat': 44.0981654, 'location_lng': -79.58613749999999, 'name': 'default', 'role': 'admin', 'role_hotspot': False}] 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] 200 text/html <ClientResponse(https://redacted.fu.com:443) [200 OK]> <CIMultiDictProxy('Vary': 'Origin', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': 'afddfdbd-47b2-4c1e-90c9-8c912b9a9a07', 'Content-Type': 'text/html; charset=utf-8', 'Content-Length': '450', 'X-Response-Time': '1ms', 'Set-Cookie': 'TOKEN=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; samesite=none; secure; httponly', 'Date': 'Thu, 07 Jul 2022 20:31:07 GMT', 'Connection': 'keep-alive')> 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/api/auth/login 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] 200 application/json <ClientResponse(https://redacted.fu.com:443/api/auth/login) [200 OK]> <CIMultiDictProxy('Vary': 'Origin', 'X-DNS-Prefetch-Control': 'off', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': '1f45e199-7b3a-4377-973e-01ce9167e058', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '6267', 'X-Response-Time': '180ms', 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2ZTA1MTNkZi0wMmNjLTRkZWItOGVjOC0xNWFkOTI5NWVmNzEiLCJjc3JmVG9rZW4iOiIxZjQ1ZTE5OS03YjNhLTQzNzctOTczZS0wMWNlOTE2N2UwNTgiLCJpYXQiOjE2NTcyMjU4NjcsImV4cCI6MTY1NzIyOTQ2NywianRpIjoiNTBiM2E1NjAtMzE1Yi00YWFkLTkyNjEtZTBmOTdjZDIwZDEyIn0.voMdNsSTrjAyx3E_7n84pugTkb0HA8lAFaCpo14-DMI; path=/; samesite=none; secure; httponly', 'Date': 'Thu, 07 Jul 2022 20:31:07 GMT', 'Connection': 'keep-alive')> 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/proxy/network/api/s/default/stat/sta 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] 200 application/json <ClientResponse(https://redacted.fu.com:443/proxy/network/api/s/default/stat/sta) [200 OK]> <CIMultiDictProxy('Vary': 'accept-encoding', 'X-DNS-Prefetch-Control': 'off', 'x-frame-options': 'DENY', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': '1f45e199-7b3a-4377-973e-01ce9167e058', 'Content-Encoding': 'gzip', 'Content-Type': 'application/json;charset=UTF-8', 'Date': 'Thu, 07 Jul 2022 20:31:07 GMT', 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2ZTA1MTNkZi0wMmNjLTRkZWItOGVjOC0xNWFkOTI5NWVmNzEiLCJjc3JmVG9rZW4iOiIxZjQ1ZTE5OS03YjNhLTQzNzctOTczZS0wMWNlOTE2N2UwNTgiLCJqdGkiOiI1MGIzYTU2MC0zMTViLTRhYWQtOTI2MS1lMGY5N2NkMjBkMTIiLCJwYXNzd29yZFJldmlzaW9uIjoxNjU3MTM4ODU3LCJpYXQiOjE2NTcyMjU4NjcsImV4cCI6MTY1NzIyOTQ2N30.G0E6kPtMmxKvlSaqH0lD4izW7fEhKHO9HtPlWAwIZMY; path=/; samesite=none; secure; httponly', 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked')> 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/proxy/network/api/s/default/rest/user 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] 200 application/json <ClientResponse(https://redacted.fu.com:443/proxy/network/api/s/default/rest/user) [200 OK]> <CIMultiDictProxy('Vary': 'accept-encoding', 'X-DNS-Prefetch-Control': 'off', 'x-frame-options': 'DENY', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': '1f45e199-7b3a-4377-973e-01ce9167e058', 'Content-Encoding': 'gzip', 'Content-Type': 'application/json;charset=UTF-8', 'Date': 'Thu, 07 Jul 2022 20:31:07 GMT', 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2ZTA1MTNkZi0wMmNjLTRkZWItOGVjOC0xNWFkOTI5NWVmNzEiLCJjc3JmVG9rZW4iOiIxZjQ1ZTE5OS03YjNhLTQzNzctOTczZS0wMWNlOTE2N2UwNTgiLCJqdGkiOiI1MGIzYTU2MC0zMTViLTRhYWQtOTI2MS1lMGY5N2NkMjBkMTIiLCJwYXNzd29yZFJldmlzaW9uIjoxNjU3MTM4ODU3LCJpYXQiOjE2NTcyMjU4NjcsImV4cCI6MTY1NzIyOTQ2N30.G0E6kPtMmxKvlSaqH0lD4izW7fEhKHO9HtPlWAwIZMY; path=/; samesite=none; secure; httponly', 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked')> 2022-07-07 16:31:07 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/proxy/network/api/s/default/stat/device 2022-07-07 16:31:08 DEBUG (MainThread) [aiounifi.controller] 200 application/json <ClientResponse(https://redacted.fu.com:443/proxy/network/api/s/default/stat/device) [200 OK]> <CIMultiDictProxy('Vary': 'accept-encoding', 'X-DNS-Prefetch-Control': 'off', 'x-frame-options': 'DENY', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': '1f45e199-7b3a-4377-973e-01ce9167e058', 'Content-Encoding': 'gzip', 'Content-Type': 'application/json;charset=UTF-8', 'Date': 'Thu, 07 Jul 2022 20:31:07 GMT', 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2ZTA1MTNkZi0wMmNjLTRkZWItOGVjOC0xNWFkOTI5NWVmNzEiLCJjc3JmVG9rZW4iOiIxZjQ1ZTE5OS03YjNhLTQzNzctOTczZS0wMWNlOTE2N2UwNTgiLCJqdGkiOiI1MGIzYTU2MC0zMTViLTRhYWQtOTI2MS1lMGY5N2NkMjBkMTIiLCJwYXNzd29yZFJldmlzaW9uIjoxNjU3MTM4ODU3LCJpYXQiOjE2NTcyMjU4NjcsImV4cCI6MTY1NzIyOTQ2N30.G0E6kPtMmxKvlSaqH0lD4izW7fEhKHO9HtPlWAwIZMY; path=/; samesite=none; secure; httponly', 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked')> 2022-07-07 16:31:08 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/proxy/network/api/s/default/rest/dpiapp 2022-07-07 16:31:08 DEBUG (MainThread) [aiounifi.controller] 200 application/json <ClientResponse(https://redacted.fu.com:443/proxy/network/api/s/default/rest/dpiapp) [200 OK]> <CIMultiDictProxy('Vary': 'Origin', 'X-DNS-Prefetch-Control': 'off', 'x-frame-options': 'DENY', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': '1f45e199-7b3a-4377-973e-01ce9167e058', 'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '30', 'Date': 'Thu, 07 Jul 2022 20:31:07 GMT', 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2ZTA1MTNkZi0wMmNjLTRkZWItOGVjOC0xNWFkOTI5NWVmNzEiLCJjc3JmVG9rZW4iOiIxZjQ1ZTE5OS03YjNhLTQzNzctOTczZS0wMWNlOTE2N2UwNTgiLCJqdGkiOiI1MGIzYTU2MC0zMTViLTRhYWQtOTI2MS1lMGY5N2NkMjBkMTIiLCJwYXNzd29yZFJldmlzaW9uIjoxNjU3MTM4ODU3LCJpYXQiOjE2NTcyMjU4NjgsImV4cCI6MTY1NzIyOTQ2OH0.iaxtkvHtaIScCZyEaBHWkC2dJKj6sSddqKcK5PQgibI; path=/; samesite=none; secure; httponly', 'Connection': 'keep-alive')> 2022-07-07 16:31:08 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/proxy/network/api/s/default/rest/dpigroup 2022-07-07 16:31:08 DEBUG (MainThread) [aiounifi.controller] 200 application/json <ClientResponse(https://redacted.fu.com:443/proxy/network/api/s/default/rest/dpigroup) [200 OK]> <CIMultiDictProxy('Vary': 'Origin', 'X-DNS-Prefetch-Control': 'off', 'x-frame-options': 'DENY', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': '1f45e199-7b3a-4377-973e-01ce9167e058', 'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '167', 'Date': 'Thu, 07 Jul 2022 20:31:07 GMT', 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2ZTA1MTNkZi0wMmNjLTRkZWItOGVjOC0xNWFkOTI5NWVmNzEiLCJjc3JmVG9rZW4iOiIxZjQ1ZTE5OS03YjNhLTQzNzctOTczZS0wMWNlOTE2N2UwNTgiLCJqdGkiOiI1MGIzYTU2MC0zMTViLTRhYWQtOTI2MS1lMGY5N2NkMjBkMTIiLCJwYXNzd29yZFJldmlzaW9uIjoxNjU3MTM4ODU3LCJpYXQiOjE2NTcyMjU4NjgsImV4cCI6MTY1NzIyOTQ2OH0.iaxtkvHtaIScCZyEaBHWkC2dJKj6sSddqKcK5PQgibI; path=/; samesite=none; secure; httponly', 'Connection': 'keep-alive')> 2022-07-07 16:31:08 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/proxy/network/api/s/default/rest/wlanconf 2022-07-07 16:31:08 DEBUG (MainThread) [aiounifi.controller] 200 application/json <ClientResponse(https://redacted.fu.com:443/proxy/network/api/s/default/rest/wlanconf) [200 OK]> <CIMultiDictProxy('Vary': 'accept-encoding', 'X-DNS-Prefetch-Control': 'off', 'x-frame-options': 'DENY', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Accept-Ranges': 'bytes', 'X-CSRF-Token': '1f45e199-7b3a-4377-973e-01ce9167e058', 'Content-Encoding': 'gzip', 'Content-Type': 'application/json;charset=UTF-8', 'Date': 'Thu, 07 Jul 2022 20:31:07 GMT', 'Set-Cookie': 'TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2ZTA1MTNkZi0wMmNjLTRkZWItOGVjOC0xNWFkOTI5NWVmNzEiLCJjc3JmVG9rZW4iOiIxZjQ1ZTE5OS03YjNhLTQzNzctOTczZS0wMWNlOTE2N2UwNTgiLCJqdGkiOiI1MGIzYTU2MC0zMTViLTRhYWQtOTI2MS1lMGY5N2NkMjBkMTIiLCJwYXNzd29yZFJldmlzaW9uIjoxNjU3MTM4ODU3LCJpYXQiOjE2NTcyMjU4NjgsImV4cCI6MTY1NzIyOTQ2OH0.iaxtkvHtaIScCZyEaBHWkC2dJKj6sSddqKcK5PQgibI; path=/; samesite=none; secure; httponly', 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked')> 2022-07-07 16:31:08 DEBUG (MainThread) [aiounifi.controller] https://redacted.fu.com:443/proxy/network/api/self/sites 2022-07-07 16:31:08 DEBUG (MainThread) [aiounifi.controller] 200 application/json <ClientResponse(https://redacted.fu.com:443/proxy/network/api/self/sites) [200 OK]>

Kane610 commented 2 years ago

Our logs look the same now @kungfuice thanks. Now to find the next one with issues...

stonith commented 2 years ago

Our logs look the same now @kungfuice thanks. Now to find the next one with issues...

It should probably be noted in the integration docs that UDM 1.12 is required? I don't have the time to downgrade and debug 1.11 either.

Kane610 commented 2 years ago

It shouldn't be 1.12. the requirement is latest stable

COCottonwood commented 2 years ago

Could this be related to PR# https://github.com/home-assistant/core/issues/74551 - "Python 3.10 ssl cipher defaults in HA 2022.7.0 break the Elk M1 integration"?

JoshuaRedmond commented 2 years ago

Updating to the latest Unifi OS (1.12.22) and Network 7.1.66) versions seems to have solved the issue for me, although I'm not sure why HA updating would have triggered the issue. Happy for this to be closed though, as it seems updating Unifi fixed it for others too.

Wedee98 commented 2 years ago

Noticed that while the Dream Machine Pro was working, when in the UI some info was not updating or blank. Rebooted the DMP and was able to recreate the integration and its working again.

UPDATE: Still working with latest HA update to 2022.7.1

Kane610 commented 2 years ago

Updating to the latest Unifi OS (1.12.22) and Network 7.1.66) versions seems to have solved the issue for me, although I'm not sure why HA updating would have triggered the issue. Happy for this to be closed though, as it seems updating Unifi fixed it for others too.

Lets keep it open a couple of days more, but it seems being on 1.12 release and 7.1.6X and having a freshly restarted system resolves this issue.

philmale commented 2 years ago

Can confirm I've had this exact error for a couple of weeks, on HA release 2022.6.6 and on 2022.7.0 and on 2022.7.1, with the UDM on 1.11.x - updating UDM Pro to version 1.12.22 this morning fixed it instantly - Network app was the latest - it was only updating the Unifi OS to 1.12.22 that fixed it.

Kane610 commented 2 years ago

Thanks for verifying @philmale UniFi is hard to get right :)

Kane610 commented 2 years ago

Closing this as multiple positive reports on upgrading to 1.12.22 and 7.1.6X or restarting the system resolves the issue.

Madseason41 commented 2 years ago

Edit: Maybe this is related to #74013

Are we sure this is fixed?

My unifi switch automations are not working correctly. I have deleted and re-added the integration and rebooted all unifi devices multiple times

I am on 1.12.22 and 7.2.88 (previously 7.2.85). I am not sure how to roll back the controller on the UDM, else I would. I may try 7.2.91 soon.

Sometimes I get a 401 error and sometimes it works.

Below is the log:

Logger: homeassistant.components.websocket_api.http.connection Source: components/unifi/switch.py:340 Integration: Home Assistant WebSocket API (documentation, issues) First occurred: 9:09:13 AM (2 occurrences) Last logged: 9:09:14 AM

[140181116171744] Call https://192.168.1.1:443/proxy/network/api/s/default/cmd/stamgr received 401 Unauthorized Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 193, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1713, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/components/homeassistant/init.py", line 124, in async_handle_turn_service await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/core.py", line 1713, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service await service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 680, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 930, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 717, in _handle_entity_call await result File "/usr/src/homeassistant/homeassistant/components/unifi/switch.py", line 340, in async_turn_on await self.controller.api.clients.unblock(self.client.mac) File "/usr/local/lib/python3.10/site-packages/aiounifi/interfaces/clients.py", line 32, in unblock return await self.controller.request( File "/usr/local/lib/python3.10/site-packages/aiounifi/controller.py", line 287, in request return await self._request(method, url, json) File "/usr/local/lib/python3.10/site-packages/aiounifi/controller.py", line 323, in _request raise LoginRequired(f"Call {url} received 401 Unauthorized") aiounifi.errors.LoginRequired: Call https://192.168.1.1:443/proxy/network/api/s/default/cmd/stamgr received 401 Unauthorized

Kane610 commented 2 years ago

Even if it's the same error the circumstances are different. Can you create a new issue?