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.07k stars 29.73k forks source link

Can't configure Ubiquiti Unifi Integration #51336

Closed gabosom closed 3 years ago

gabosom commented 3 years ago

The problem

Can't get past the Integration configuration screen due to an "unknown error"

Interation image

What is version of Home Assistant Core has the issue?

core-2021.5.5

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

Ubiquiti Unifi

Link to integration documentation on our website

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

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: aiohttp.server
Source: components/unifi/controller.py:493
First occurred: 7:39:43 AM (5 occurrences)
Last logged: 7:39:52 AM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 74, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 135, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 131, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 155, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 63, 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 199, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 257, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/unifi/config_flow.py", line 94, in async_step_user
    controller = await get_controller(
  File "/usr/src/homeassistant/homeassistant/components/unifi/controller.py", line 493, in get_controller
    await controller.login()
  File "/usr/local/lib/python3.8/site-packages/aiounifi/controller.py", line 108, in login
    await self._request("post", url=url, json=auth)
  File "/usr/local/lib/python3.8/site-packages/aiounifi/controller.py", line 274, in _request
    async with self.session.request(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 542, in _request
    resp = await req.send(conn)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 668, in send
    await writer.write_headers(status_line, self.headers)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/http_writer.py", line 118, in write_headers
    buf = _serialize_headers(status_line, headers)
  File "aiohttp/_http_writer.pyx", line 137, in aiohttp._http_writer._serialize_headers
  File "aiohttp/_http_writer.pyx", line 109, in aiohttp._http_writer.to_str
TypeError: Cannot serialize non-str key None


### Additional information

_No response_
probot-home-assistant[bot] commented 3 years ago

Hey there @kane610, mind taking a look at this issue as its been labeled with an integration (unifi) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

Kane610 commented 3 years ago

I've never seen that error before. How is your controller setup? Have you tried running it with a previous release of home assistant?

nicolaiort commented 3 years ago

Hi maybe I can help add more information, I just got the same error.

Unifi Controller

Home-assistant

Happy to provide more information, just tell me what you need and I'll do my best :)

gabosom commented 3 years ago

Sorry for the delay. Here's my info:

Unifi Controller

Home Assistant

image

Home Assistant and Cloudkey are on the same network.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

gabosom commented 3 years ago

hey @nicolaiort and @Kane610 - I got this working today by doing the following:

  1. Updated the controller to the latest version
  2. Created a brand new local user in the controller (the new controller UI didn't work, I had to go back to classic for that)
  3. Used port 8443 instead of 443.

Good luck!

nicolaiort commented 3 years ago
  • Created a brand new local user in the controller (the new controller UI didn't work, I had to go back to classic for that)

@gabosom Thank you for the tip - I use the controller on my CloudKey Gen2 with UnifiOS and this method of deployment doesn't allow creation of users in the controller UI - only in the CloudKey management UI afaik (could be me not looking in the right place).

Are you running the contoller on a CloudKey G2/Dream Machine or standalone?

gabosom commented 3 years ago

I use a cloudkey. Just create an admin with read only access 😉

nicolaiort commented 3 years ago

Well I don't know what the heck I did different this time but it works. Created the UnifiOS User, gave access to my site (same user and permissions as last time) , and added the integration on port 443 (8443 is only for non g2/UnifiOS controllers).

Thank you @gabosom for encouraging me to try it again :)

Kane610 commented 3 years ago

Closing this issue as its been resolved