UniFi Protect
The UniFi Protect integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] adds support for retrieving camera feeds and sensor data from a UniFi Protect application
Prerequisites
Hardware support
This integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] supports all UniFi OS Consoles that can run UniFi Protect. Currently, this includes:
- Any UniFi Protect Network Video Recorder (UNVR
or UNVRPRO ) - Any UniFi “Dream” device (UDMPRO
, UDR , or UDMSE ), except the base UniFi Dream Machine/UDM - UniFi Cloud Key Gen2 Plus (UCKP
) firmware version v2.0.24+
UCKP with Firmware v1.x do NOT run UniFi OS, you must upgrade to firmware v2.0.24
Software support
The absolute minimal software version is v1.20.0
Early Access and Release Candidate versions are not supported by Home Assistant.
Using Early Access Release Candidate versions of UniFi Protect or UniFi OS will likely cause your UniFi Protect integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] to break unexpectedly. If you choose to opt into either the Early Access or the Release Candidate release channel and anything breaks in Home Assistant, you will need to wait until that version goes to the official Stable Release channel before it is expected to work.
Local user
You will need a local user created in your UniFi OS Console to log in with. Ubiquiti SSO Cloud Users will not work. It is recommended you use the Administrator or a user with full read/write access to get the most out of the integration, but it is not required. The entities that are created will automatically adjust based on the permissions of the user you use has.
- Login to your Local Portal on your UniFi OS device, and click on Users. Note: This must be done from
the UniFi OS by accessing it directly by IP address (i.e. Local Portal), not via
unifi.ui.com
or within the UniFi Protect app. - Go to Admins from the left hand side menu or [IP address]/admins/users e.g. 192.168.1.1/admins/users.
- Click on Add New Admin.
- Select Full Management for the role. Uncheck Allow Remote Access and fill out the fields for your user.
- Click Add in the bottom right.
Camera streams
The integration uses the RTSP(S) Streams as the Live Feed source, so this needs to be enabled on each camera to ensure you can stream your camera in Home Assistant. This may already be enabled by default, but it is recommended to just check that this is done. To check and enable the feature:
- Open UniFi Protect and click on Devices.
- Select the camera you want to ensure can stream in UniFi Protect.
- Click the Settings tab in the top right.
- Expand the Advanced section at the bottom.
- Enable a minimum 1 stream out of the 3 available. The Stream with the Highest resolution is the default enabled one.
Configuration
To add the UniFi Protect hub to your Home Assistant instance, use this My button:
UniFi Protect can be auto-discovered by Home Assistant. If an instance was found, it will be shown as Discovered. You can then set it up right away.
Manual configuration steps
If it wasn’t discovered automatically, don’t worry! You can set up a manual integration entry:
-
Browse to your Home Assistant instance.
-
In the bottom right corner, select the
Add Integration button. -
From the list, select UniFi Protect.
-
Follow the instructions on screen to complete the setup.
Device support
All known UniFi Protect devices should be supported. Each UniFi Protect device will get a variety of entities added for each of the different entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] platforms.
Permissions: The below sections on the features available to your Home Assistant instance assume you have full write access to each device. If the user you are using has limited access to some devices, you will get fewer entities and in many cases, get a read-only sensor instead of an editable switch/select/number entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more].
UniFi Protect cameras
Smart Detections: The following cameras have Smart Detections:
- All “AI” series cameras. This includes the AI 360
and the AI Bullet . - All “G4” series cameras. This includes the G4 Doorbell
, G4 Bullet , G4 Pro and G4 Instant .
G3 Series cameras do not have Smart detections.
Each UniFi Protect camera will get a device in Home Assistant with the following:
-
Camera - A camera for each camera channel and RTSP(S) combination found for each camera (up to 7). Only the highest resolution RTSPS camera entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] will be enabled by default.
- If your camera is a G4 Doorbell Pro, an additional camera entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] will be added for the Package Camera. The Package Camera entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] will not have streaming capabilities regardless of whether RTSPS is enabled on the channel or not. This is due to the Package Camera having a very low FPS that does not make it compatible with HLS streaming.
- Media Player - If your camera has a speaker, you will get a media player entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] that allows you to play audio to your camera’s speaker. Any audio file URI that is playable by FFmpeg will be able to be played to your speaker, including via the TTS Say action.
- Privacy Mode - If your camera allows for Privacy Masks, there will be a configuration switch to toggle a “Privacy Mode” that disables recording, microphone, and a black privacy zone over the whole camera.
-
Sensors - Sensors include “Is Dark”, “Motion Detected”, detected object sensors (if the camera supports smart detections), and “Doorbell Chime” (if the camera has a chime). Several diagnostics sensors are added including sensors on uptime, network connection stats, and storage stats. Doorbells will also have a “Voltage” sensor for troubleshooting electrical issues.
- There is one detected object sensor per Smart Detection supported by the camera and a combined sensor for if any object is detected.
-
Device Configuration - Cameras will get various configuration controls based on the features available to the camera. Currently provided configuration controls:
- configuration sliders for Chime Type, Zoom Level, Microphone Sensitivity, and WDR Level
- configuration switches Overlay Information, Smart Detections types, Status Light, HDR, High FPS mode, System Sounds
- configuration text and select for LCD Screen for doorbells to either set custom messages or use predefined messages
- Button - A disabled by default button is added for each camera device. The button will let you reboot your camera device.
UniFi Protect floodlights
Each UniFi Protect floodlight will get a device in Home Assistant with the following:
- Light - A light entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] will be added for each floodlight device. The light entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] will let you control turning on or off your light as well as adjust the brightness of your floodlight.
- Sensors - Sensors are provided for data provided from floodlight devices. Sensors include “Is Dark” and “Motion Detected”.
- Device Configuration - Floodlights will get configuration controls for the PIR Motion Sensitivity, the Auto-shutoff Duration after detected motion, and Status Light switch
- Button - A disabled by default button is added for each floodlight device. The button will let you reboot your floodlight device.
UniFi Protect smart sensors
UniFi Protect smart sensors are a bit different than normal sensors. They are a multi-sensor that can act as a contact sensor (door/window), a motion detector, a light level detector, a humidity sensor, a temperature level sensor, an alarm sound sensor, and/or a leak detector. Each sensor function can be enabled or disabled dynamically. Disabled sensors will be marked as “unavailable”.
-
Sensors - A sensor is provided for each major function of the smart sensor device:
- Contact - A contact sensor will be available if the mount type is set as “Door”, “Window” or “Garage”.
- Motion Detection - A motion detection sensor will be available if the mount type is not set to “Leak” and motion detection is enabled.
- Light Level - A light level sensor will be available if the mount type is not set to “Leak” and the light sensor is enabled.
- Humidity - A humidity sensor will be available if the mount type is not set to “Leak” and the humidity sensor is enabled.
- Temperature - A temperature sensor will be available if the mount type is not set to “Leak” and the temperature sensor is enabled.
- Alarm Sound - An alarm sensor will be available if the mount type is not set to “Leak” and the alarm sound sensor is enabled. The Alarm Sound sensor can have the values “none”, “smoke” and “co”. More values may be added over time automatically as UniFi Protect adds support for detecting more alarms.
- Tamper - A binary sensor to detect tampering.
- Device Configuration - Smart sensors will get configuration controls for the Status Light, enabling/disabling all of the main sensors, selecting the Paired Camera, and changing the Mount Type of the sensor.
- Button - A button to clear the tampered state as well as a disabled by default button to restart the device.
Tamper sensor
Once the tamper sensor is triggered, it stays active until manually cleared. A button entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] is available to clear the tampered state.
UniFi Protect viewers
Each UniFi Protect viewer will get a device in Home Assistant with the following:
- Liveview Select - A select control will be added for each viewer device that will allow you to select which liveview is being displayed on the viewer.
- Button - A disabled by default button is added for each viewer device. The button will let you reboot your viewer device.
UniFi Protect DoorLock
Each UniFi Protect door lock will get a device in Home Assistant with the following:
- Lock - A lock control will be added to lock and unlock your door lock device.
- Device Configuration - Door locks will get configuration controls for the Auto-Lock Timeout, selecting the Paired Camera, and Status Light switch
- Button - A disabled by default button is added for each door lock device. The button will let you reboot your door lock device.
UniFi Protect Smart Chime
Each UniFi Protect smart chime will get a device in Home Assistant with the following:
- Button - A button to trigger the chime manually for each smart chime device. Also, a disabled by default button is added to let you reboot your smart chime device.
- Device Configuration - Smart chimes will get a volume slider to adjust the chime’s loudness and a sensor for the last time the chime rang.
NVR
Your main UniFi Protect NVR device also gets a number of diagnostics sensors that can be used for tracking the state of your UniFi Protect system:
- Disk Health: Each disk installed in your NVR will have a disk health sensor. These are simple good/bad sensors and the order is not promised to match the order in UniFi OS. Disk model number is provided as a state attribute though to help map sensor to disk.
- Utilization and Storage Sensors: Several other sensors are also added for uptime, hardware utilization, and distribution details of the video on disk.
Media source
A media source is provided for your UniFi Protect cameras so you can fetch video clips and event thumbnails.
Media browser
The media source is split into 5 folders/levels:
- NVR Console Selector - only appears if you have more then one Protect NVR Console. Allows you to select your NVR Console you want to view events for.
- Camera Selector - either lets you select all cameras or a specific camera to view events for.
- Event Selector - either lets you select all events or a specific event type to view events for.
- Time Selector - filters events for a given time range:
- Last 24 Hours
- Last 7 Days
- Last 30 Days
- By Month since start of recording - selecting a month lets you either view the whole month or a specific date
- Event Selector - lets you select the specific event for playback
Since the media browser does not have any pagination or filtering, all of the events must be loaded into memory. As a result, the number of events loaded at once is truncated to 10,000 by default. The number of events will be listed at “10000 (TRUNCATED)” if the event count was truncated. You can raise or lower the limit of the number of events that can be loaded using the Config Entry Options.
Media identifiers
Below are the accepted identifiers to resolve media. Since events do not necessarily map to any Home Assistant entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more], all IDs are in reference to the UniFi Protect IDs, not Home Assistant ones.
Identifier Format | Description |
---|---|
{nvr_id}:event:{event_id} |
MP4 video clip for specific event. |
{nvr_id}:eventthumb:{event_id} |
JPEG thumbnail for specific event. |
Actions
Action unifiprotect.add_doorbell_text
Adds a new custom message for Doorbells.
Data attribute | Optional | Description |
---|---|---|
device_id |
No | Any device from the UniFi Protect instance you want to change. In case you have multiple Protect instances. |
message |
No | New custom message to add for Doorbells. Must be less than 30 characters. |
Action unifiprotect.remove_doorbell_text
Removes an existing message for Doorbells.
Data attribute | Optional | Description |
---|---|---|
device_id |
No | Any device from the UniFi Protect instance you want to change. In case you have multiple Protect instances. |
message |
No | Existing custom message to remove for Doorbells. |
Action unifiprotect.set_chime_paired_doorbells
Use to set the paired doorbell(s) with a smart chime.
Data attribute | Optional | Description |
---|---|---|
device_id |
No | The device ID of the Chime you want to pair or unpair doorbells to. |
doorbells |
Yes | A target selector for any number of doorbells you want to pair to the chime. No value means unpair all. |
Action unifiprotect.remove_privacy_zone
Use to remove a privacy zone from a camera.
Data attribute | Optional | Description |
---|---|---|
device_id |
No | Camera you want to remove privacy zone from. |
name |
No | The name of the zone to remove. |
Views
The integrationsIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] provides two proxy views to proxy media content from your Home Assistant instance so you can access thumbnails and video clips from within the context of Home Assistant without having to expose your UniFi Protect NVR Console. As with the media identifiers, all IDs are UniFi Protect IDs as they may not map to specific Home Assistant entities depending on how you have configured your integrationsIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more].
These URLs work great when trying to send notifications. Home Assistant will automatically sign the URLs and make them safe for external consumption if used in an automationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more] or notify action.
Two URLs for proxy API endpoints:
/api/unifiprotect/thumbnail/{nvr_id}/{event_id}:
- Proxies a JPEG event thumbnail from UniFi Protect.
/api/unifiprotect/video/{nvr_id}/{camera_id}/{start}/{end}
:
- Proxies a MP4 video clip from UniFi Protect for a specific camera. Start and end must be in ISO 8601 format
.
nvr_id
can either be the UniFi Protect ID of your NVR or the config entry ID for your UniFi Protect integrationsIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more]. camera_id
can either be the UniFi Protect ID of your camera or an entity ID of any entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] provided by the UniFi Protect integrationsIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] that can be reversed to a UniFi Protect camera (i.e., an entity ID of a detected object sensor).
The easiest way to find the nvr_id
, camera_id
, start
, and end
times is by viewing one of the videos from UniFi Protect in the Media browser. If you open the video in a new browser tab, you will see all these values in the URL. The start
time is the last_changed timestamp of the event when the sensor started detecting motion. The end
time is the last_changed timestamp of the event when the sensor stopped detecting motion. Similarly, to see the event_id
of the image, go to Developer Tools > States and find the event when the sensor started detecting motion.
When a Doorbell rings, there is a specific event entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] that provides the event_id
. You can use this to get the thumbnail, for example, event.g4_doorbell_pro_doorbell
.
Troubleshooting
Delay in video feed
The default settings on the stream integration will give you a 5-15+ second delay. You can reduce this delay to 1-3 seconds, by enabling LL-HLS in the stream integration. You will also want to put an HTTP/2 reverse proxy in front of Home Assistant so you can have connection pooling. If you do not add a reverse proxy, you may start to get “Waiting for WebSocket…” messages while trying to view too many camera streams at once. One way to do this is using the official NGINX Proxy Add-on:
Cannot play audio to speakers
Unlike with many other things, playing audio to your speakers requires your Home Assistant to be able to reach your camera directly. Specifically via port tcp/7004
. You can enable debug logging and it will output the full FFmpeg command that will be run and the output from FFmpeg to help you troubleshoot why audio is not playing to the device.
Liveview options for viewer missing options or out of date
Main control selects currently cannot have dynamic options since the options are exported out to voice assistants. After you add/remove/change a Liveview in UniFi Protect, you must restart Home Assistant to get the new options for your Viewer.
NvrErrors with “404 - Reason: Not Found” or “502 - Reason: Bad Gateway”
If you get errors while authenticating or fetching data for NvrError... 404 - Reason: Not Found
, there is a good chance that your UniFi Protect application has crashed. UniFi Protect runs in a supervised way on UniFi OS (similar to Home Assistant OS + Home Assistant Core). Getting a 404 for a URL that should not produce a 404 means UniFi Protect is probably not running. You may want to check the health of your disks or look into debugging UniFi Protect to see why it is crashing.
Similarly, a 502 Bad Gateway
also means that your UniFi Protect application may not be running.
uiprotect.NvrError: Fetching Camera List failed: 404 - Reason: Not Found