Unifi Protect (failed to connect)


It looks like the Unifi Protect plugin is broken after an update and no longer functions? All the entities report as “recovered” or “unavailable”. This was previously working before I updated Home Assistant.

I’ve attempted to bin the integration and set it up again but it won’t accept my login details anymore with “Unknown Error” or “Failed to connect” despite this all working flawlessly before. I have setup a new user in Unifi OS with Super Admin rights and still no joy.

Unifi OS: v3.2.12
Unifi Protect: v3.0.10

Home Assistant:
Core: 2024.3.0
Supervisor: 2024.02.1
Operating System: 12.0
Frontend: 20240306.0
HACS: 1.34.0


I was a bit silly and forgot I sat my UDMP on Early Access and so Unifi Protect updated from 2.11.21 (official) to 3.0.10 (early access) breaking the integration in the process.

For anyone who finds they’ve done the same you can SSH into your UDMP and issue the following commands to force a downgrade.

  • SSH into UDM-PRO
  • apt-get update
  • apt-get install --reinstall --allow-downgrades unifi-protect=2.11.21 -y

Replace ‘2.11.21’ to whatever version suits.

You installed early access (v. 3.x)? 2024.3: Drag 'n Drop it like it's hot! 🎉 - #61 by Holdestmade

Yeah spot on, I’ve updated my post. I somehow forgot to change it back. Fixed by force installing the official 2.11.21 over the EA access.

1 Like

Done the same, however downgrading still having no effect.
HA still saying Unknown error occurred

same here. downgraded to 2.11.21, unkonow error occurred

Same here, the read only user is left over though when downgrading, I assume that’s what the readlive error is. We’ll just have to wait patiently for it to be fixed

EDIT: Looking at github, it looks like its been fixed and merged, hopefully it’ll make it in 2024.3.2

Just updated to Unifi Protect 3.0.22 (official release channel) and home assistant no longer connecting to cameras etc. Suggest not to update protect until the integration is updated.

1 Like
1 Like

With how fickle the integration is, I ended up just adding Generic Cameras pointing at the RTSP and snapshot links. Yes, I lose the person / motion detection, but I don’t end up with random crashes of the integration and it seems to load the snapshots more quickly (and more often).

Once the integration is operational again, I’ll probably keep the Generic Camera one as the primary for images and just use the motion / person detection from the integration.

1 Like

Do you mind sharing an example of your configuration using Generic Cameras ?
Teste the following combinations and both fail to render:

  - platform: generic
    name: kitchenunifi
    still_image_url: http://unifiprotectIP/snap.jpeg
    stream_source: rtsps://unifiprotectIP:7441/streamingID?enableSrtp
    verify_ssl: false

or simply:

- platform: generic
    name: kitchenunifi
    still_image_url: http://CAMERA_IP/snap.jpeg
    stream_source: rtsp://USERNAME:PASSWORD@CAMERA_IP:7447/STREAM_ID

There is any specific user I need to create in order to make it working ?

Your second one is closest – but the RTSP link needs to be pulled from the Camera Settings page in Protect, with changes to the port and protocol.

the snap.jpeg only comes from the camera, and the rtsp only comes from the protect appliance (and seems to be anonymous). I’ve attached what I configured in the UI.

1 Like

Appreciate. How do u get this options UI ?And I see you have Basic Authentication defined, username\pwd is for a specific user within the UnifiProtect ? or your kept without anything ?

BTW, I managed to fix my integration and udpate to the last Unifi fwm using the following Unifi Protect Integration does not yet support Protect 3.0.10 · Issue #112487 · home-assistant/core (github.com)

If you update to 2024.3.2 it solves the Protect v3.x issue

I can’t, because of other dependencies. The change I did this morning on types.py is the fix included on 2024.3.2

There’s quite a few more changes/fixes but if what you’ve done works for you that’s great

1 Like

I added the “Generic Camera” integration through Settings → Devices & Services → Integrations. Then, after selecting the integration, I clicked “Add Entry” at the bottom.

It says “Basic Authentication” but the u/p info is blank. Those were defaults that I tried first and they worked.

I think it’s only fair to say it solves the Protect v.3.0.x issue. I’ve watched this integration get broken with other releases within the same major release, too.

If you do not like how the library is developed, then why don’t you stop bitching and contribute?

Dude… if it breaks because Ubiquiti sneezes, it’s pretty hard to support. I’m not a python programmer, so I won’t be contributing code – it would just cause you more work.

To be clear, I’m not bitching in a way that expects you to do anything – I’ve found a workaround by using Generic Camera for the image / video stream (which works better even when this integration is working since it grabs the snapshots directly from the camera, and more often). If I need to use the sensors for automations, I just use the Node-RED integration that doesn’t break with every minor change.

I don’t understand how it is that other integrations (Scrypted, Node-RED, probably others) don’t go kaboom at the slightest change, but this one seems to need everything perfect in order to not blow up. In any other API work I’ve done, everything is backwards compatible (unless otherwise stated), and a tool programmed against an older API will work, just without the new features.

The other integrations do not implement half of the features pyunifiprotect does. And most of them are untyped. Just like UniFi Protect is. Javascript tends to keep working even when it is working flat out wrong because it is designed to. There is a reason why there are so many jokes about how Javascript typing works.

pyunifiprotect sometimes has to deal with this as result of how bad Protect can be sometimes.

pyunifiprotect usually breaks for 1 of 3 reasons:

New typing change that Python could not handle (most common one including the most recent one). It is not usually normal in decently made Python code to just pass around strings for everything like Javascript does. You make enums. You validate the values of things. When a new value is added, if you have not actually added the code to be able to handle the new value, it can case issues. It is really easy to reproduce and understand this issue with an example:

from enum import Enum

class Animal(Enum):
    CAT = "cat"
    DOG = "dog"

ValueError: 'bird' is not a valid Animal

Every time this happens, I keep improving all of the enums and types so they can better adapt to unknown values, but there are a lot of values. Other times Ubiquiti just fucks up the values (which leads to the second time).

The second, and also the second most common, reason things break is because Ubiquiti fucks up a lot. Like a lot. There is a reason a lot of people say their software is buggy and unstable. The last time the integration broke from everyone updating to the EA version was because UI completely foobar’d how they were handling UUIDs and Javascript’s shitty typing just allowed them to go with it. In fact, people that did not update to EA did not have this issue because it was fixed in a later EA build so stable never had the issue.

The third, and probably least common, issue is just that Ubiquiti decides to make a breaking change because they can. Because Protect does not have an open API and they can and will do whatever they want with it. Like they completely changed how events worked in 2.11 which completely broken the license plate sensors in Home Assistant because Home Assistant expects sensors to have state. The events started only coming in after they completed which basically left them with no state. 3.0.x actually seems to have reversed this change so the license plate sensors work again.

Just the server version of UniFi Protect (not including the Web app client any of the mobile apps or UI Core or anything else) is over 50,000 lines long. So yeah, sometimes I miss something. Or something I wait a week or two to update pyunifiprotect after an EA version releases, because, you know, I am a human being and have to deal with idiots like you saying how bad I am at everything I do. Or people not blinding auto-updating to EA and then harassing me because their Home Assistant broke.