Custom Component: Unifi Protect

No, that service is actually not really useful. It tries to use the latest “event” thumbnail image which is not always consistency correct and will lead to very varied results. See Thumbnail image not/rarely available for doorbell · Issue #265 · briis/unifiprotect · GitHub for details.

1 Like

Yea I tried to use that recently and got a nice zoomed in image of the event but if I checked it after the person detection took place it was just my flag blowing in the wind. :yum:

Ah ok, I’ve not used it as I use the UNIFI Protect motion detection sensor to trigger snapshots and plate recognition in HA automation. This keeps one image as the latest and keeps all the others with datestamp

- alias: Drive Camera Vehicle Motion
  max_exceeded: silent
  trigger:
    - platform: state
      entity_id: binary_sensor.motion_drive_camera
      attribute: event_object
      to: 'vehicle'
  action:
    - service: camera.snapshot
      data:
        filename: /config/www/snapshots/drive_camera_latest.png
      target:
        entity_id: camera.drive_camera
    - service: camera.snapshot
      data:
        filename: /media/motion/drive_camera_snapshot_{{ now().strftime("%d%m%Y - %H-%M-%S") }}.png
      target:
        entity_id: camera.drive_camera
    - delay: '00:00:03'
    - service: image_processing.scan
      target:
        entity_id: image_processing.platerecognizer_drive_last_motion
1 Like

Version 0.10.0 Beta 4 released

REMINDER This version is only valid for V1.20.0-beta.2 or higher of UniFi Protect. If you are not on that version, stick with V0.9.1.

Upgrade Instructions

Due to the many changes and entities that have been removed and replaced, we recommend the following process to upgrade from an earlier Beta or from an earlier release:

  • Upgrade the Integration files, either through HACS (Recommended) or by copying the files manually to your custom_components/unifiprotect directory.
  • Restart Home Assistant
  • Remove the UniFi Protect Integration by going to the Integrations page, click the 3 dots in the lower right corner of the UniFi Protect Integration and select Delete
  • While still on this page, click the + ADD INTEGRATION button in the lower right corner, search for UnFi Protect, and start the installation, supplying your credentials.

Changes in this release

This will be the last beta with functional changes, so after this release it will only be bug fixes. The final release will come out when 1.20 of UniFi Protect is officially launched. Everything from Beta 1, 2 and 3 is included here, plus the following:

  • NEW: Device Configuration URL’s are introduced in Home Assistant 2021.11. In this release we add URL Link to allow the user to visit the device for configuration or diagnostics from the Devices page. If you are not on HA 2021.11+ then this will not have any effect on your installation.

  • NEW: BREAKING CHANGE Also as part of Home Assistant 2021.11 a new Entity Category is introduced. This makes it possible to classify an entity as either config or diagnostic. A config entity is used for entities that can change the configuration of a device and a diagnostic entity is used for devices that report status, but does not allow changes. These two entity categories have been applied to selected entities in this Integration. If you are not on HA 2021.11+ then this will not have any effect on your installation.

    We would like to have feedback from people on this choice. Have we categorized too many entities, should we not use this at all. Please come with the feedback.

    Entities which have the entity_category set:

    • Are not included in a service call targetting a whole device or area.
    • Are, by default, not exposed to Google Assistant or Alexa. If entities are already exposed, there will be no change.
    • Are shown on a separate card on the device configuration page.
    • Do not show up on the automatically generated Lovelace Dashboards.
  • NEW: A switch is being created to turn on and off the Privacy Mode for each Camera. This makes it possible to set the Privacy mode for a Camera directly from the UI. This is a supplement to the already existing service unifiprotect.set_privacy_mode

  • NEW: Restarted the work on implementing the UFP Sense device. We don’t have physical access to this device, but @Madbeefer is kindly enough to do all the testing.

    • The following new sensors will be created for each UFP Sense device: Battery %, Ambient Light, Humidity, Temperature and BLE Signal Strength.
    • The following binary sensors will be created for each UFP Sense device: Motion, Open/Close and Battery Low. Note as of this beta, these sensors are not working correctly, this is still work in progress.
1 Like

Is it possible to use TTS with the UniFi Doorbell? Ie that HA can speak via the doorbell instead of just displaying a message?

I’m not sure how many people actually take note of that little screen…

As of right now, no. But it is a planned feature. It will likely come in 0.11 or 0.12 (which 0.12 might be in HA core since we plan to merge into core).

4 Likes

I’m planning on making the move across to Protect v1.20.0 and v0.10.x of the Protect component this weekend.
In the meantime I’ve been reading up on the new LL-HLS option for Stream and wondered whether anyone here has given it a whirl with Protect. Any hints / tips?

We had a bit of discussion about it in the feature request I made right around the same time it was added.

The tldr; is that it works great and decreases the latency from ~15 seconds to ~3, but if you use it, you need to set up a HTTP/2 or HTTP/3 proxy in front of your HA instance (the official nginx add-on works great). If you do not do that, you can only have a max of like ~2-3 cameras streaming at any given time (across all sessions).

Thanks for responding (and so quickly).

I’m running with HA Container in docker on Ubuntu, Nabu Casa for external access and have 4 Unifi cameras.

Based on a quick read of the linked discussion my current setup may not be suitable but I might have a play once I’ve completed the move to the latest Protect and the reworked Integration.

What happens if you have more than 3. I have 6 cameras and all are working fine but I haven’t yet setup my “camera dashboard” with all the cams at once. Curious to know what to expect when I do. I’m using Nabucasa so no reverse proxy.

I do not use Nabu Casa so I do not know if it already provides a HTTP/2 proxy, but I assume it does. So you may already be set. If you also want it for internal as well, that means you will likely need to set up your own Nginx proxy for internal access since you do not have the add-on store. I am sure you can find plenty of guides for how to create Nginx proxies. I know Nginx Proxy Manager is a pretty popular option.

You get a “waiting for Websocket…” message and the browser just hangs until one of the other connections are closed.

3 is an estimate. I do not know what the actual limit is. I have 6 cameras as well too and I was running into the issue. Just remember that it is across all browsers connected to Home Assistant. So if more than one person accessing your HA instance and you both access it at once, it will be doubled (6 connections per user).

1 Like

Thanks for the details. I’m familiar with NPM. I use it for other purposes outside of Home Assistant.

I use the custom frigate-card on the front-end for my Unifi cameras, since upgrading to Protect v1.20.0 and v0.10.x I receive an error when trying to view live video:

Error: Support only RTSP-Stream

I’m wondering if this is being caused by the switch to RTSPS. Is there any way to force RTSP?

From the Protect changelog:

  • Web UI: Generate only RTSPS links for better security. (RTSP streams are still available by removing S from RTSPS and by changing port 7441 to 7447)

Thx @stephack , I can’t see that part in the release notes. Does the document you see tell you where to make that change? :confused:

No. Not in the HA integration. RTSP links were removed from the WebUI in Unifi Protect. That could be an indication it will be removed in a future release. RTSPS works completely with Home Assistant as it uses ffmpeg to stream.

Frigate is also a third party integration and is largely in conflict with UFP for functionality. If you would like RTSPS to work in your Frigate card, I recommend asking the Frigate devs to support cameras with RTSPS.

1 Like

Just in case anyone else runs into the issue with the frigate-card looks like the issue is not with frigate or indeed that card, rather the WebRTC custom component. I’ll open a request there for it to support RTSPS.

This Unifi Protect upgrade from 1.19.x to 1.20 complete messed up all of my camera feeds.

Further more having WebRTC installed messed it up even further. So I had to uninstall it for now.

I’m unable to start the unifi protect integration I get the follow error:

Error setting up entry UDMPRO for unifiprotect
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/config/custom_components/unifiprotect/__init__.py", line 108, in async_setup_entry
    await _async_get_or_create_nvr_device_in_registry(hass, entry, nvr_info)
  File "/config/custom_components/unifiprotect/__init__.py", line 124, in _async_get_or_create_nvr_device_in_registry
    device_registry.async_get_or_create(
TypeError: async_get_or_create() got an unexpected keyword argument 'configuration_url'

Is anybody having the same issue?

My current work around for this is to use RTSP streams for my cameras.

  1. Copy the RTSPS link from unifi protect. Example: rtsps://192.168.25.1:7441/labcdefgh?enableSrtp

  2. Remove the s in rtsps and change the port from 7441 to 7447

  3. Add to configuration.yaml

 - platform: ffmpeg
    input: rtsp://192.168.25.1:7447/abcdefgh?enableSrtp
    name: Garage

The 0.10 version of the integration requires Protect 1.20+ to use. In turn, 0.10 of the integration also requires Home Assistant 2021.11+ to use. This was unfortunate timing that both HA and Protect introduced non-backwards compatible changes at the same time.

If you cannot upgrade your HA instance to 2021.11, I recommend downgrading your Protect instance back to 1.19 and then using 0.9.1 of the integration.

Also, the WebRTC component will no longer work with the Protect integration as it does use the RTSPS links from Protect now. Protect 1.20 removed the non-secure links from the UI. We suspect that Ubiquiti will remove the non-secure links in a future version so we are using the secure links since they work great in HA. I recommend bugging the author of the WebRTC component to support RTSPS if you would like to keep using it. Otherwise, you can enable LL-HLS on your HA instance (you can see more conversation about LL-HLS right above your post).

If you cannot get the extension author to support RTSPS and you really need WebRTC, I recommend going to go vote for this feature request: WebRTC support for Camera (stream) Components

We pushed out a hotfix for 0.10 just now. We temporarily removed the “High FPS Mode” switch as it was being incorrectly added to cameras that did not support High FPS mode, which could lead the device being bricked. If you are running 0.10.0, please update ASAP. The High FPS mode switch will be added back in a future version once we ensure it does not get added to cameras that do not have the mode.

Apologizes if changelogs in HACS are wrong and not displaying correctly. We had to push it out in a hurry.

1 Like