After update Ubiquiti Unifi integration can no longer access "Options"

I’m running core-2021.1.5 and right after I updated I tried to make a change to the Unifi integration. I had originally set the integration to ‘not’ track devices and later needed to change that back to tracking. Each time I have tried to click ‘Options’ to make the change, I get a “Please wait while the integration is being installed” and it just spins and spins for over an hour. It’s in some kind of loop.

I’m not sure where to report this on Github (I’m not that familiar with how that works).

Has anyone else had this issue?

Same. I’ve had the issue for quite some time now. I haven’t dared try removing and readding incase it messes up the entity names.

Here’s the error from my logs:

Logger: aiohttp.server
Source: components/unifi/config_flow.py:179
First occurred: 2:47:59 PM (2 occurrences)
Last logged: 3:09:27 PM
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 118, 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 72, in ban_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/auth.py”, line 127, in auth_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/view.py”, line 129, in handle
result = await result
File “/usr/src/homeassistant/homeassistant/components/config/config_entries.py”, line 210, in post
return await super().post(request)
File “/usr/src/homeassistant/homeassistant/components/http/data_validator.py”, line 60, in wrapper
result = await method(view, request, *args, **kwargs)
File “/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py”, line 69, in post
result = await self._flow_mgr.async_init(
File “/usr/src/homeassistant/homeassistant/data_entry_flow.py”, line 130, in async_init
result = await self._async_handle_step(
File “/usr/src/homeassistant/homeassistant/data_entry_flow.py”, line 213, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File “/usr/src/homeassistant/homeassistant/components/unifi/config_flow.py”, line 179, in async_step_init
self.controller = self.hass.data[UNIFI_DOMAIN][self.config_entry.entry_id]
KeyError: ‘…scrubbed…’

I think I found the problem. Ubiquiti recently issued a security warning and recommended using 2 factor authentication; which I turned on.

aiounifi.errors.TwoFaTokenRequired: api.err.Ubic2faTokenRequired

Well, I was right. Once I turned off 2 factor, as well as disabling remote access and reloading HA, everything returned to normal.

You can also keep 2fa and create a local account as suggested by the integration documentation

1 Like

I read the documentation about creating a read-only user, which I did. I used that account when setting up the integration while 2FA was running and the integration failed. Once I turned off 2FA, the integration could complete the process. When creating accounts, I don’t see a “local” designation. Do you mean “read-only” when you say “local”? The account was created on the unifi-controller under “Admins”. Did I miss something?

A local account can be either admin or read only. I don’t run a standalone controller so I can’t say what exactly you’d need to do

Are you creating the account when logged in to the controller’s user management screen via the direct IP address (rather than via unifi.ui.com)? From my Cloud Key Gen2+, running v2.0.27

Screenshot 2021-04-02 14.23.08

A local account will show “Local Access” rather than “Ubiquiti Account”:

1 Like

I think the prompts are different for the Cloud Key. Here’s a screen shot from the unifi controller (unifi.ui.com).


I think what might be the equivalent of your solution is to uncheck the “Enable Remote Access” checkbox. I’ll try it.