Custom Component: Unifi Protect

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

After discussing it, we decided to add back the RTSP Camera entities. In 0.11, there will be up to 6 camera entities (if RTSP is enabled for all 3 of your camera channels):

  • High (RTSPS)
  • High Insecure (RTSP)
  • Medium (RTSPS)
  • Medium Insecure (RTSP)
  • Low (RTSPS)
  • Low Insecure (RTSP)

Only the high resolution RTSPS camera entity will be enabled by default, but you will be free to enable any of the other 5. If you have RTSP disabled on your High channel and only enabled on your Medium channel, that will be your default enabled one.

EDIT: Discourse does not like me replying to our own integration thread.

Turned my personal notification automations into blueprints and posted them if anyone else is interested or wants to contribute.

Version 0.11.0-beta.1 is released

@AngellusMortis and @bdraco have spend a significant amount of hours in the last weeks to add a whole bunch of new features to this Integration and to prepare it for getting added to Home Assistant Core.

As you can see from below, there are quite a significant number of changes and new features also in this release, so please read these release notes carefully before you upgrade.

Deprecations

0.11 is last major release planned before we merge the unifiprotect integration into core. As a result, a number of features are being removed when we merged into core.

The following services will be removed in the next version:

  • unifiprotect.set_recording_mode – use the select introduced in 0.10 instead
  • unifiprotect.set_ir_mode – use the select entity introduced in 0.10 instead
  • unifiprotect.set_status_light – use the switch entity on the camera device instead
  • unifiprotect.set_hdr_mode – use the switch entity on the camera device instead
  • unifiprotect.set_highfps_video_mode – use the switch entity on the camera device instead
  • unifiprotect.set_doorbell_lcd_message – use the select entity introduced in 0.10 instead
  • unifiprotect.set_mic_volume – use the number entity introduced in 0.10 instead
  • unifiprotect.set_privacy_mode – use the switch entity introduced in 0.10 instead
  • unifiprotect.set_zoom_position – use the number entity introduced in 0.10 instead
  • unifiprotect.set_wdr_value – use the number entity introduced in 0.10 instead
  • unifiprotect.light_settings – use the select entity introduced in 0.10 instead
  • unifiprotect.set_viewport_view – use the select entity introduced in 0.10 instead

The following events will be removed in the next version:

  • unifiprotect_doorbell – use a State Changed event on “Doorbell” binary sensor on the device instead
  • unifiprotect_motion – use a State Changed event on the “Motion” binary sensor on the device instead

The following entities will be removed in the next version:

  • The “Motion Recording” sensor for cameras (in favor of the “Recording Mode” select)
  • The “Light Turn On” sensor for flood lights (in favor of the “Lighting” select)

All of following attributes should be duplicated data that can be gotten from other devices/entities and as such, they will be removed in the next version.

  • device_model will be removed from all entities – provided in the UI as part of the “Device Info”
  • last_tripped_time will be removed from binary sensor entities – use the last_changed value provided by the HA state instead
  • up_since will be removed from camera and light entities – now has its own sensor. The sensor is disabled by default so you will need to enable it if you want to use it.
  • enabled_at will be removed from light entities – now has its own sensor
  • camera_id will be removed from camera entities – no services need the camera ID anymore so it does not need to be exposed as an attribute. You can still get device IDs for testing/debugging from the Configuration URL in the “Device Info” section
  • chime_duration, is_dark, mic_sensitivity, privacy_mode, wdr_value, and zoom_position will be removed from camera entities – all of them have now have their own sensors

Breaking Changes in this release

  • CHANGE: BREAKING CHANGE The internal name of the Privacy Zone controlled by the “Privacy Mode” switch has been changed. Make sure you turn off all of your privacy mode switches before upgrading. If you do not, you will need to manually delete the old Privacy Zone from your UniFi Protect app.

  • CHANGE: BREAKING CHANGE WDR number entity has been removed from Cameras that have HDR. This is inline with changes made to Protect as you can no longer control WDR for cameras with HDR.

  • CHANGE: BREAKING CHANGE the event_length attribute has been removed from the motion and door binary sensors. The value was previously calculated in memory and not reliable between restarts.

  • CHANGE: BREAKING CHANGE the event_object attribute for binary motion sensors has changed the value for no object detected from “None Identified” (string) to “None” (NoneType/null)

  • CHANGE: BREAKING CHANGE The Doorbell Text select entity for Doorbells has been overhauled. The Config Flow option for Doorbell Messages has been removed. You now can use the the unifiprotect.add_doorbell_text and unifiprotect.remove_doorbell_text services to add/remove Doorbell messages. This will persist the messages in UniFi Protect and the choices will now be the same ones that appear in the UniFi Protect iOS/Android app. NOTE: After running one of these services, you must restart Home Assistant for the updated options to appear.

Other Changes in this release

  • CHANGE: Migrates UpvServer to new ProtectApiClient from pyunifiprotect.

    • This should lead to a number of behind-the-scenes reliability improvements.
      • Should fix/close the following issues: #248, #255, #297, #317, #341, and #360 (TODO: Verify)
  • CHANGE: Overhaul Config Flow

    • Adds Reauthentication support
    • Adds “Verify SSL”
    • Updates Setup / Reauth / Options flows to pre-populate forms from existing settings
    • Removes changing username/password as part of the options flow as it is redundant with Reauthentication support
    • Removes Doorbell Text option since it is handled directly by UniFi Protect now
    • Adds new config option to update all metrics (storage stat usage, uptimes, CPU usage, etc.) in realtime. WARNING: Enabling this option will greatly increase your CPU usage. ~2x is what we were seeing in our testing. It is recommended to leave it disabled for now as we do not have a lot of diagnostic sensors using this data yet.
  • CHANGE: The state of the camera entities now reflects on whether the camera is actually recording. If you set your Recording Mode to “Detections”, your camera will switch back and forth between “Idle” and “Recording” based on if the camera is actually recording.

    • Closes #337
  • CHANGE: Configuration URLs for UFP devices will now take you directly to the device in the UFP Web UI.

  • CHANGE: Default names for all entities have been updated from entity_name device_name to device_name entity_name to match how Home Assistant expects them in 2021.11+

  • CHANGE: The Bluetooth strength sensor for the UP Sense is now disabled by default (will not effect anyone that already has the sensor).

  • NEW: Adds all of the possible enabled UFP Camera channels as different camera entities; only the highest resolution secure (RTSPS) one is enabled by default. If you need RTSP camera entities, you can enable one of the given insecure camera entities.

  • NEW: Added the following attributes to Camera entity: width, height, fps, bitrate and channel_id

  • NEW: Added status light switch for Flood Light devices

  • NEW: Added “On Motion - When Dark” option for Flood Light Lighting switch

  • NEW: Added “Auto-Shutoff Timer” number entity for Flood Lights

  • NEW: Added “Motion Sensitivity” number entity for Flood Lights

  • NEW: Added “Chime Duration” number entity for Doorbells

  • NEW: Added “Uptime” sensor entity for all UniFi Protect adoptable devices. This is disabled by default.

  • NEW: Added unifiprotect.set_default_doorbell_text service to allow you to set your default Doorbell message text. NOTE: After running this service, you must restart Home Assistant for the default to be reflected in the options.

  • NEW: Added “SSH Enabled” switch for all adoptable UniFi Protect devices. This switch is disabled by default.

  • NEW: (requires 2021.12+) Added “Reboot Device” button for all adoptable UniFi Protect devices. This button is disabled by default. Use with caution as there is no confirm. “Pressing” it instantly reboots your device.

  • NEW: Added media player entity for cameras with speaker. Speaker will accept any ffmpeg playable audio file URI (URI must be accessible from Home Assistant, not your Camera). TTS works great!

    • TODO: Investigate for final release. This may not work as expected on G4 Doorbells. Not sure yet if it is because of the recent Doorbell issues or because Doorbells are different.
    • Implements #304
6 Likes

Cameras stream in HA seems to be delayed for about 7 seconds comparing to live view in Protect. Is there a way to decrease the delay? Thank you.

1 Like

Check these out:

That helped. Now I have only 1 second delay. Thank you very much).

Hi there. Im fairly new to HA and am trying to integrate my UNVR. Once i’ve entered the ip address, username and password and click next i get the error “Unifi Protect version is not supported by this integration”

Ive follow a few guides and youtube videos, created a user with local admin and enabled the rstp stream.

Can anyone shed any light on if this is just something im missing or is this a current known issue??

Thanks.

You probably need to upgrade UniFi Protect: Integration is not supported post HASS upgrade · Issue #365 · briis/unifiprotect · GitHub

(or downgrade the HA integration)

1 Like

Amazing thank you.

Release 0.11.0

Deprecations

0.11 is last major release planned before we merge the unifiprotect integration into core. As a result, a number of features are being removed when we merged into core.

The following services will be removed in the next version:

  • unifiprotect.set_recording_mode – use the select introduced in 0.10 instead
  • unifiprotect.set_ir_mode – use the select entity introduced in 0.10 instead
  • unifiprotect.set_status_light – use the switch entity on the camera device instead
  • unifiprotect.set_hdr_mode – use the switch entity on the camera device instead
  • unifiprotect.set_highfps_video_mode – use the switch entity on the camera device instead
  • unifiprotect.set_doorbell_lcd_message – use the select entity introduced in 0.10 instead
  • unifiprotect.set_mic_volume – use the number entity introduced in 0.10 instead
  • unifiprotect.set_privacy_mode – use the switch entity introduced in 0.10 instead
  • unifiprotect.set_zoom_position – use the number entity introduced in 0.10 instead
  • unifiprotect.set_wdr_value – use the number entity introduced in 0.10 instead
  • unifiprotect.light_settings – use the select entity introduced in 0.10 instead
  • unifiprotect.set_viewport_view – use the select entity introduced in 0.10 instead

The following events will be removed in the next version:

  • unifiprotect_doorbell – use a State Changed event on “Doorbell” binary sensor on the device instead
  • unifiprotect_motion – use a State Changed event on the “Motion” binary sensor on the device instead

The following entities will be removed in the next version:

  • The “Motion Recording” sensor for cameras (in favor of the “Recording Mode” select)
  • The “Light Turn On” sensor for flood lights (in favor of the “Lighting” select)

All of following attributes should be duplicated data that can be gotten from other devices/entities and as such, they will be removed in the next version.

  • device_model will be removed from all entities – provided in the UI as part of the “Device Info”
  • last_tripped_time will be removed from binary sensor entities – use the last_changed value provided by the HA state instead
  • up_since will be removed from camera and light entities – now has its own sensor. The sensor is disabled by default so you will need to enable it if you want to use it.
  • enabled_at will be removed from light entities – now has its own sensor
  • camera_id will be removed from camera entities – no services need the camera ID anymore so it does not need to be exposed as an attribute. You can still get device IDs for testing/debugging from the Configuration URL in the “Device Info” section
  • chime_duration, is_dark, mic_sensitivity, privacy_mode, wdr_value, and zoom_position will be removed from camera entities – all of them have now have their own sensors
  • event_object will be removed from the Motion binary sensor. Use the dedicated Detected Object sensor.

Breaking Changes in this release

  • CHANGE: BREAKING CHANGE The internal name of the Privacy Zone controlled by the “Privacy Mode” switch has been changed. Make sure you turn off all of your privacy mode switches before upgrading. If you do not, you will need to manually delete the old Privacy Zone from your UniFi Protect app.

  • CHANGE: BREAKING CHANGE WDR number entity has been removed from Cameras that have HDR. This is inline with changes made to Protect as you can no longer control WDR for cameras with HDR.

  • CHANGE: BREAKING CHANGE the event_length attribute has been removed from the motion and door binary sensors. The value was previously calculated in memory and not reliable between restarts.

  • CHANGE: BREAKING CHANGE the event_object attribute for binary motion sensors has changed the value for no object detected from “None Identified” (string) to “None” (NoneType/null)

  • CHANGE: BREAKING CHANGE The Doorbell Text select entity for Doorbells has been overhauled. The Config Flow option for Doorbell Messages has been removed. You now can use the the unifiprotect.add_doorbell_text and unifiprotect.remove_doorbell_text services to add/remove Doorbell messages. This will persist the messages in UniFi Protect and the choices will now be the same ones that appear in the UniFi Protect iOS/Android app. NOTE: After running one of these services, you must restart Home Assistant for the updated options to appear.

Other Changes in this release

  • CHANGE: Migrates UpvServer to new ProtectApiClient from pyunifiprotect.

    • This should lead to a number of behind-the-scenes reliability improvements.
      • Should fix/close the following issues: #248, #255, #297, #317, #341, and #360 (TODO: Verify)
  • CHANGE: Overhaul Config Flow

    • Adds Reauthentication support
    • Adds “Verify SSL”
    • Updates Setup / Reauth / Options flows to pre-populate forms from existing settings
    • Removes changing username/password as part of the options flow as it is redundant with Reauthentication support
    • Removes Doorbell Text option since it is handled directly by UniFi Protect now
    • Adds new config option to update all metrics (storage stat usage, uptimes, CPU usage, etc.) in realtime. WARNING: Enabling this option will greatly increase your CPU usage. ~2x is what we were seeing in our testing. It is recommended to leave it disabled for now as we do not have a lot of diagnostic sensors using this data yet.
  • CHANGE: The state of the camera entities now reflects on whether the camera is actually recording. If you set your Recording Mode to “Detections”, your camera will switch back and forth between “Idle” and “Recording” based on if the camera is actually recording.

    • Closes #337
  • CHANGE: Configuration URLs for UFP devices will now take you directly to the device in the UFP Web UI.

  • CHANGE: Default names for all entities have been updated from entity_name device_name to device_name entity_name to match how Home Assistant expects them in 2021.11+

  • CHANGE: The Bluetooth strength sensor for the UP Sense is now disabled by default (will not effect anyone that already has the sensor).

  • NEW: Adds unifiprotect.set_doorbell_message service. This is just like the unifiprotect.set_doorbell_lcd_message, but it is not deprecated and it requires the Doorbell Text Select entity instead of the Camera entity. Should only be used to set dynamic doorbell text messages (i.e. setting the current outdoor temperate on your doorbell). If you want to use static custom messages, use the Doorbell Text Select entity and the unifiprotect.add_doorbell_text / unifiprotect.remove_doorbell_text service. unifiprotect.set_doorbell_lcd_message is still deprecated and will still be removed in the next release.

    • Closes #396
  • NEW: Adds “Override Connection Host” config option. This will force your RTSP(S) connection IP address to be the same as everything else. Should only be used if you need to forcibly use a different IP address.

    • For sure closes #248
  • NEW: Added Dark Mode brand images to GitHub - home-assistant/brands: 🎨 Brands for Home Assistant.

  • NEW: Adds phy_rate and wifi_signal sensors so all connection states (BLE, WiFi and Wired) should have a diagnostic sensor. Disabled by default. Requires “Realtime metrics” option to update in realtime.

  • NEW: Added Detected Object sensor for cameras with smart detections. Values are none, person or vehicle. Contains event_score and event_thumb attributes.

    • Closes #342
  • NEW: Adds Paired Camera select entity for Viewports

  • NEW: Adds “Received Data”, “Transferred Data”, “Oldest Recording”, “Storage Used”, and “Disk Write Rate” sensors for cameras. Disabled by default. Requires “Realtime metrics” option to update in realtime.

  • NEW: (requires UniFi Protect 1.20.1) Adds “Voltage” sensor for doorbells. Disabled by default.

  • NEW: Adds “System Sounds” switch for cameras with speakers

  • NEW: Adds switches to toggle overlay information for video feeds on all cameras

  • NEW: Adds switches to toggle smart detection types on cameras with smart detections

  • NEW: Adds event thumbnail proxy view.

    • URL is /api/ufp/thumbnail/{thumb_id}. thumb_id is the ID of the thumbnail from UniFi Protect.
    • entity_id is a required query parameters. entity_id be for an sensor that has event thumbnails on it (like the Motion binary sensor)
    • token is a required query parameter is you are not authenticated. It is an attribute on the motion sensor for the Camera
    • w and h are optional query string params for thumbnail resizing.
  • NEW: Adds event_thumbnail attribute to Motion binary sensor that uses above mentioned event thumbnail proxy view.

  • NEW: Adds NVR sensors. All of them are disabled by default. All of the sensors will only update every ~15 minutes unless the “Realtime metrics” config option is turned on. List of all sensors:

    • Disk Health (one per disk)
    • System Info: CPU Temp, CPU, Memory and Storage Utilization
    • Uptime
    • Recording Capacity (in seconds)
    • Distributions of stored video for Resolution (4K/HD/Free)
    • Distributions of stored video for Type (Continuous/Detections/Timelapse)
  • More clean up and improvements for upcoming Home Assistant core merge.

  • Adds various new blueprints to help users automate UniFi Protect. New Blueprints can be found in the README

9 Likes

Just want to say thank you for all the effort that has gone into this component over recent times. Utterly amazing than you!

Just started playing with dynamic text on the doorbell, so cool what is now possible.

2 Likes

Great reminder by @Eoin to be grateful for all the work that is done. So…

Thank you @briis :crown:

1 Like

Thank you for your efforts on this Component !

I am trying to use this, but running into issues (UnifiProtect: Person detect notification event_thumbnail not working for me)
Any pointers as to what i am (probably) doing wrong ?

We need to document this better, but unfortunately UniFi Protect does not generate the event thumbnail until after the event ends. So, you cannot actually use them real-time notification unless you do a state changed for the event ending and use the thumbnail URL from the old state (I know it sucks).

We already have official blueprints that send mobile push notifications you can use if you want. That is why we did not use the event thumbnails for the blueprints. Favoring speed to get the notification out rather than using the event thumbnail.

Thanks for the explanation, the choice for the blueprint makes sense.

For my use case, it’s OK to only send the notification after the event ends.
Am I correct in guessing that’s just a matter of using this as a trigger?

platform: state
entity_id: sensor.<name>_detected_object
from: person

Is there any documentation on how to access the “old state” in an elegant way?

Yes. That works fine. And it should be in trigger.from_state.