Unifi Protect (failed to connect)

Can i ask what versions of software you have for HA & Unifi Protect?

I have latest of both (offical not early access) and still get “Failed to connect”

+1 :
Protect 3.0.26

  • Core 2024.4.2
  • Supervisor 2024.04.0
  • Operating System 12.2

failed to connect error when setting up. Have previously had it working, using same credentials. Was initially hit by the dumb EA bug from unifi and thought I just needed to reinstall to get rid of the EA alert when the camera streams went down. Whoops

have read the recent threads. Am aware it’s a complex issue and will take time. Just posting for ?value of having more info & appreciate the work you do AngellusMortis.

1 Like

-1
After updating to 2024.4.4 I was able to set up the protect integration without an error message.
protect hasn’t been updated or changed
unclear as to why it works or what is different, but it’s fixed for me

I’ve had a steady Unifi Protect connection for the past month or so, but woke up this morning to HA telling me my Unifi Protect ‘Authentication Expired’. I put in the local username and pwd and received a message stating ‘Invalid Authentication’. I changed the local pwd and got the same result.

Anyone else seen this?

same problem here

I had what I thought was a local account but by virtue of it having been connected to the cloud at one time it - was considered a cloud account at one time (by some unknown rule) and the UniFi integration was barking at me about the upcoming mfa stuff.

I killed the account and rebuilt it completely locally on the UDM and it hasn’t complained yet. Did you ever give that account you’re using a external email or hook it to the cloud?

No. The account is not linked to an email address and I have never accessed it outside my LAN.

Now my unifi integration also failed. I am on 4.0.3

1 Like

Ah I’m still on a 3.0.x build…

Looks like some issues with EA 4.0.3:

Go into Unifi Console and create a new local user account for HA. The Protect integration logged in on 1st attempt. Trying to set up Network integration is not fixed by this method.

I’m having the same issue, “unknown error occurred”

  • Core 2024.5
  • Operating System 12.2
  • Protect 3.0.26

I’m using a local Unifi user.

Hi all, was just about to chime in with the same problem. I downloaded HA today and have been trying to set it up solely for the UniFi Protect integration, followed all steps (nice guides, btw), but kept getting the “failed to connect” error. I realized I was copy/pasting the URL for my UniFi console… just typed the IP address only and it worked. Feels like an obvious mistake now, but figured I’d leave it here anyway. Here’s my versions:
HA Core 2024.5.4
HA OS 12.3
UniFi OS v3.2.12
UniFi Protect v3.0.26

v4 of Unifi Protect went GA a few days ago and broke my integration. I’m running HA 2024.5.5.
When I try to readd the integration I just get an unknown error in the UI.
This error is in the HA logs

2024-05-30 18:42:51.736 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/local/lib/python3.12/site-packages/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/ban.py", line 88, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp_session/__init__.py", line 199, in factory
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/auth.py", line 295, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/decorators.py", line 71, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/http/data_validator.py", line 73, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/data_entry_flow.py", line 368, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/data_entry_flow.py", line 414, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/data_entry_flow.py", line 518, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/unifiprotect/config_flow.py", line 343, in async_step_user
    nvr_data, errors = await self._async_get_nvr_data(user_input)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/homeassistant/components/unifiprotect/config_flow.py", line 271, in _async_get_nvr_data
    bootstrap = await protect.get_bootstrap()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/api.py", line 1132, in get_bootstrap
    return Bootstrap.from_unifi_dict(**data, api=self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 127, in from_unifi_dict
    data = cls.unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/bootstrap.py", line 224, in unifi_dict_to_dict
    return super().unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 376, in unifi_dict_to_dict
    data[key] = cls._clean_protect_obj_dict(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 318, in _clean_protect_obj_dict
    items[key] = cls._clean_protect_obj(value, klass, api)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 296, in _clean_protect_obj
    return klass.unifi_dict_to_dict(data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/devices.py", line 985, in unifi_dict_to_dict
    return super().unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 1005, in unifi_dict_to_dict
    return super().unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 866, in unifi_dict_to_dict
    return super().unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 362, in unifi_dict_to_dict
    data[key] = cls._clean_protect_obj(data[key], unifi_objs[key], api)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 296, in _clean_protect_obj
    return klass.unifi_dict_to_dict(data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/devices.py", line 504, in unifi_dict_to_dict
    return super().unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/data/base.py", line 355, in unifi_dict_to_dict
    data[key] = convert_unifi_data(data[key], cls.__fields__[key])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyunifiprotect/utils.py", line 251, in convert_unifi_data
    return type_(value)
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/enum.py", line 744, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/enum.py", line 1158, in __new__
    raise ve_exc
ValueError: 'IMAGE' is not a valid DoorbellMessageType

I’ve got the same issue with 2024.5.5. Tried removing, adding, debug… all the same.

Delete the user in unifi and create a new one. You can try deleting and creating a new user with the same name/password. I didn’t think of it until afterward, I deleted the integration and re added with the new user.

I figured it out. It breaks if you enable a custom image in the doorbell.

3 Likes

@albert.pender Yes. That is exactly what happened to mine today. Thank you!

Thank you @albert.pender

however,

OH MY GOD!!! This doorbell image is fighting to the DEATH to not work. Unbelievable!

I just had to reboot my HA Green. My protect integration is no longer working.

It worked fine with the new Protect update for the last several days.

It was only until I rebooted my HA that it broke the integration.

EDIT: I removed the custom doorbell image, and switched back to my NO SOLICITING message.

Now the Unifi Protect integration works.

Thanks @albert.pender

Hoping this might help others:

Upgraded HA to 2024.6.3 which broke Unifi Protect (v3.0.26)
Getting “Failed Setup, Unable to connect to host” (or similar in HA)

Then upgraded Unifi Protect to v4.0.33 (from v3.0.26), hoping this would fix HA integration.
Nope, same problem.
Rebooted everything, no good.

Found this conversation.

Created a new local only user in Unifi Protect.
Deleted Unifi Protect integration in HA.
Added Unifi Protect integration in HA, using the new user.

Fixed - All Good Again.

Note: I do not have a doorbell image, only a text message.

Interestingly, HomeBridge Unifi Protect plugin worked happily through all of the above upgrades and reboots without any problems. I use HomeBridge to front the Unifi Protect Cameras into Apple HomeKit (Not HA) because HomeBridge supports HKSV and does seem to be more reliable.

1 Like