Custom Component: Unifi Protect

Thank you for guidance. Works like a charm.
Now some testing.
Have a great day.

Release 0.5.5 is out

The latest beta of Unifi Protect includes the start of Ubiquitiā€™s version of AI, and introduces a concept called Smart Detect, which currently can identify People on specific Camera models. When this is enabled on a Camera, the event type changes from a motion event to a smartdetect event, and as such these cameras will no longer trigger motion events.

This release is a quick fix for the people who have upgraded to the latest Unifi Protect Beta version. I will later introduce more Integration features based on these new Unifi Protect features.

It should show in HACS as an update.

2 Likes

Hi Bjarne,

Thatā€™s amazing and also needed by Ubiquiti.
Do you have a link where the program of what devices that will be included?

You have to be registered as Beta Tester with Ubiquiti to see the release notes for the Beta software. But aside from that, it is not mentioned anywhere I have seen. I have 2 x G4 Pro, 2 x G3 Flex and 1 x G3 Micro, and only the G4 cameras support Smart Detect at present. I also believe that the Doorbell supports it, but cannot test that.

EDIT: Just found a line stating that current only the G4 Series of Cameras is supported. Which fits with my observations.

Hi, I have just installed the integration and everything works fine as expected, thanks a lot for the great work.
However, I have one question; When I add the camera to lovelace then the live preview refreshes the image every 10 seconds, is there a way to get a permanent livestream somehow ?
That would be great! Thanks a lot!

Not currently, see Custom Component: Unifi Protect

camera_view: live 

will give you a stream that is about 10 to 15 seconds behind the actual live view in the Protect app.

Thanks, works fantastic ! :+1: :+1:

I run Unifi Protect on a Unifi NVR, I also have a UDMP (that doesnā€™t run Protect).

It isnā€™t clear to me if I should enter my UDMP username/password, or something else?

When I use my UDMP local username, I get the error ā€œError retrieving data from Unifi Protect.ā€ Note if I change the username/password, I then get an authentication error - so seems like it is connecting, but is unable to see my NVR.

Hi,
In order to get this to work, you need to:

  • Create a local user on your UniFi NVR with admin rights
  • Use the IP Address of the UniFi NVR and port 443
  • And then use the above when you setup the Integration

Your UDMP is not relevant for this Integration as it does not run UniFi Protect.
Hope this helps

/B

that worked! i had to restart my NVR as for some reason it had IP address n [which I could ping] but the interface listed IP address y [which I could not ping] - restarting made the two IP addresses the same, and now it works. Thanks again.

1 Like

Wow awesome integration, thank you @briis

Does someone know, how to deep link into the iOS Protect app?
I own the Unifi Doorbell and would like to build an actionable iOS notification, which provides me with a Snapshot picture when a doorbell Ringing event occurs, but would also like offer the direct option to jump from the HA notification into the Unifi Protect app (directly into the doorbell) to do 2 Way Audio If needed. Any ideas? Jumping directly into Protect should be possible with something like:

url: ā€˜app_name://app_nameā€™

direct linking should be something like this:

url: ā€˜alexa://alexa?fragment=settingsā€™

However, I donā€™t know the deep link URL for Protect to jump directly to a camera/doorbell.
Really cool would also to be able to jump directly to a certain camera including a specific timestamp to check on the recording.

Hi,

Ok iā€™ve just read this topic between the lines.
In summary, can i say that the unifi doorbell has an integration already in HA?

  • so that u can livestream the camera?
  • u can have automations started on doorbell press?

Do i need unifi protect / a unifi cloudkey to store videos? Or can i store the videos locally when using rstp?

Thx

Yes to your two bullets - Livestream works but with a 15 sec delay (Cannot be fixed at the moment) and there is a Binary sensor that is activated when your doorbell is pressed.

You need Unifi Protect running for this to work in the first place. Unfi Protect requires dedicated HW from Ubiquiti - CloudKey+, UDMP or UNVR, which are all supported by this integration. And this is also where the Recordings are stored.

Looks like the perfect doorbell so farā€¦, that means (although the unifi doorbell has no google home support), i can still stream cams and TTS message to google home devices through home assistant, heck even messages to my sonos/tv

Right?

Only down side so far, is indeed, iā€™m obliged to buy a cloudkey gen 2+ device for the doorbell (pretty expensive doorbell then)

Someone knows what this error message is responsible for?

Log Details (ERROR)
Logger: aiohttp.server
Source: custom_components/unifiprotect/camera.py:188
First occurred: 3:37:52 PM (1 occurrences)
Last logged: 3:37:52 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 458, 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/real_ip.py", line 39, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, 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/camera/__init__.py", line 499, in get
    return await self.handle(request, camera)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 516, in handle
    image = await camera.async_camera_image()
  File "/config/custom_components/unifiprotect/camera.py", line 188, in async_camera_image
    last_image = await self.upv_object.get_snapshot_image_direct(
  File "/usr/local/lib/python3.8/site-packages/pyunifiprotect/unifi_protect_server.py", line 574, in get_snapshot_image_direct
    raise NvrError(
pyunifiprotect.unifi_protect_server.NvrError: Direct Snapshot failed: 401 - Reason: Unauthorized

I guess the main thing is this: Direct Snapshot failed: 401 - Reason: Unauthorized
Do all cameras have to have anonymous Snapshots enabled?

There was a time where the API needed this for some users, so I enabled the option in the Config. And if this is enabled, you have to enable it on each camera. But it will now work without this for all users. Please go to the Integrations page, and click option on the Unfi Protect Integration, and remove the mark in the checkbox about Anonymous Snapshots - if it is set.

2 Likes

Release 0.5.6

New feature: Turn the Status Light on or off, asked for in Issue #102. With this release there is now the possibility to turn the Status light on each camera On or Off. This can be done in two ways:

  1. Use the service unifiprotect.set_status_light
  2. Use the new switch that will be created for each camera.

The Homebridge integration of Unifi Protect done by @hjdhjd has implemented Websocket support and thus moving from pull to push, which I would really love to have here also to minimize the load on HA.
@adrum has already done a first pass at this, and is still working on it. Once this work is completed, I will need some help in implementing it in the Integration. (Just a heads up :sweat_smile:)

7 Likes

Iā€™m really looking forward to the websocket support as most of my event loop has been optimized away except for the frequent protect polling. This will solve the last little performance issue for me :smile:

2 Likes

Looks like Unifi are preparing to bring out a (lower cost) wifi camera for the Protect ecosystem - the G3 instant.
Itā€™s in early access in the US from what Iā€™ve read over the last couple of days (Iā€™m in the UK and donā€™t use EA), priced at ~ $29 dollars.

Information is limited at the moment, but Iā€™ve been looking to replace my existing cloud-based internal cameras for some time, so this might be worth waiting for.

2 Likes