Skip to content
Unifi Protect Integration for Home Assistant
Python
Branch: master
Clone or download
Latest commit 04b5177 Jan 8, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
custom_components/unifiprotect Updated Examples Jan 8, 2020
images Delete user_setup.png Dec 26, 2019
.gitignore Updated Gitignore Dec 27, 2019
CHANGELOG.md Updated CHANGELOG Jan 8, 2020
LICENSE Initial commit Dec 26, 2019
README.md Updated documentation Jan 7, 2020
hacs.json Merge branch 'master' into V0.0.10 Jan 8, 2020
info.md Updated documentation Jan 7, 2020

README.md

Unifi Protect for Home Assistant

GitHub release (latest by date including pre-releases) hacs_badge

This is a Home Assistant Integration for Ubiquiti's Unifi Protect Surveillance system.

This Home Assistant integration is inspired by danielfernau's video downloader program and the Authorization implementation is copied from there.

Basically what this does, is integrating the Camera feeds from Unifi Protect in to Home Assistant, and furthermore there is an option to get Binary Motion Sensors and Sensors that show the current Recording Settings pr. camera.

Prerequisites

Before you install this Integration you need to ensure that the following two settings are applied in Unifi Protect:

  1. Local User needs to be added Open Unifi Protect in your browser. Click the USERS tab and you will get a list of users. Either select and existing user, or create a new one. The important thing is that the user is part of Administrators and that a local username and password is set for that user. This is the username and password you will use when setting up the Integration later.
  2. RTSP Stream Select each camera under the CAMERAS tab, click on the camera and you will get a menu on the right side. Click the MANAGE button and there will be a menu like the picture below. (If you can't see the same picture click the + sign to the right of RTSP). Make sure that at least one of the streams is set to on. It does not matter which one, or if you select more than one. The integration will pick the one with the highest resolution.

USER Settings RTSP Settings

Note: This has been testet on Unifi Protect Controller version 1.13.0-beta.16, and I cannot guarantee that this will work on a lower version than that.

Manual Installation

To add Unifi Protect to your installation, create this folder structure in your /config directory:

custom_components/unifiprotect. Then, drop the following files into that folder:

__init__.py
manifest.json
sensor.py
binary_sensor.py
camera.py
protectnvr.py
services.yaml

HACS Installation

This Integration is part of the default HACS store. Search for unifi protect under Integrations and install from there.

Configuration

Start by configuring the core platform. No matter which of the entities you activate, this has to be configured. The core platform by itself does nothing else than establish a link the Unifi Protect NVR, so by activating this you will not see any entities being created in Home Assistant.

Edit your configuration.yaml file and add the unifiprotect component to the file:

# Example configuration.yaml entry
unifiprotect:
  host: <Internal ip address of your Unifi Protect NVR>
  username: <your local Unifi Protect username>
  password: <Your local Unifi Protect Password>

host:
(string)(Required) Type the IP address of your Unifi Protect NVR. Example: 192.168.1.10

username:
(string)(Required) The local username you setup under the Prerequisites section.

password
(string)(Required) The local password you setup under the Prerequisites section.

Camera

The Integration will add all Cameras currently connected to Unifi Protect. If you add more cameras, you will have to restart Home Assistant to see them in Home Assistant.

Remember

  • if you already setup the camera using another platform, like the Generic IP Platform then remove those before you setup this Platform, as cameras with the same name cannot co-exist.
  • Also, if you are running your Home Assistant installation directly on a Mac, you might need to enable stream: in your configuration.yaml to be able to do live streaming.

Edit your configuration.yaml file and add the unifiprotect component to the file:

# Example configuration.yaml entry
camera:
  - platform: unifiprotect

The Integration adds specific Unifi Protect services and supports the standard camera services. Not all have been testet but the following are working:

Service Parameters Description
camera.disable_motion_detection entity_id - camera to disable motion on Disable motion detection on the specified camera
camera.enable_motion_detection entity_id - camera to enable motion on Enable motion detection on the specified camera
camera.snapshot entity_id - Name of entity to create snapshots from.
filename - Filename to store snapshot in
Take a snapshot of the current image on the specified camera and stor in a file
camera.record entity_id - camera to record from
filename - Template of a Filename. Variable is entity_id. Must be mp4.
duration - (Optional) Target recording length (in seconds).
lookback - (Optional) Target lookback period (in seconds) to include in addition to duration. Only available if there is currently an active HLS stream.
Record the current stream to a file
unifiprotect.save_thumbnail_image entity_id - Name of entity to retrieve thumbnail from.
filename - Filename to store thumbnail in
image_width - (Optional) Width of the image in pixels. Height will be scaled proportionally. Default is 640.
Get the thumbnail image of the last recording event (If any), from the specified camera

Note: When using camera.enable_motion_detection, Recording in Unfi Protect will be set to motion. If you want to have the cameras recording all the time, you have to set that in Unifi Protect App.

Binary Sensor

If this component is enabled a Binary Motion Sensor for each camera configured, will be created.

In order to use the Binary Sensors, add the following to your configuration.yaml file:

# Example configuration.yaml entry
binary_sensor:
  - platform: unifiprotect

There is a little delay for when this will be triggered, as the way the data is retrieved is through the Unifi Protect event log, and that has a small delay before updated.

Note: This will only work if Recording state is set to motion or always as there is nothing written to the event log, if recording is disabled.

Sensor

If this component is enabled a Sensor describing the current Recording state for each camera configured, will be created.

In order to use the Sensors, add the following to your configuration.yaml file:

# Example configuration.yaml entry
sensor:
  - platform: unifiprotect

The sensor can have 3 different states:

  1. never - There will be no recording on the camera
  2. motion - Recording will happen only when motion is detected
  3. always - The camera will record everything, and motion events will be logged in Unfi Protect
You can’t perform that action at this time.