Unifi Protect plarform plugin for Homebridge
This plugin is intended to automatically configure all the cameras you have setup in UniFi Protect to make them available via HomeKit. It supports UniFi CloudKey Gen2+ and UniFi Dream Machine Pro and should support any device that can run UniFi Protect. It requires the homebridge-camera-ffmpeg plugin in order to provide that functionality.
This package is based on the excellent work of homebridge-camera-unifi.
This plugin aims to be a one-stop-shop for UniFi Protect to HomeKit connectivity. Over time, it is my hope to add motion sensors and any other capabilities that make sense to this plugin to enable HomeKit users to easily connect the UniFi Protect and HomeKit worlds.
- UniFi Dream Machine Pro (UnifiOS support)
- Support for motion detection and motion events. I would love to add this functionality but most of the approaches to implementing this right now involve hacks like monitoring the logs in realtime on Protect and trying to parse what it's telling us on the motion front. Additionally, the active development and evolution of motion detection on Protect right now (circa mid 2020) makes this a moving target. TL;DR: it's on the radar, but I'm waiting until there are better options to implementing this in a reasonable way.
If you are new to Homebridge, please first read the Homebridge documentation.
Install homebridge:
sudo npm install -g --unsafe-perm homebridgeInstall homebridge-camera-ffmpeg:
sudo npm install -g --unsafe-perm homebridge-camera-ffmpegInstall homebridge-unifi-protect2:
sudo npm install -g homebridge-unifi-protect2You will need a working ffmpeg installation for this plugin to work. Configuring ffmpeg is beyond the scope of this manual. Please refer to the excellent documentation for homebridge-camera-ffmpeg.
Adding cameras requires the same steps outlined in homebridge-camera-ffmpeg. Install the accessories and use the Homebridge setup code for the camera accessories.
After restarting Homebridge, each camera you defined will need to be manually paired in the Home app, to do this:
- Open the Home
app on your device.
- Tap the Home tab, then tap
.
- Tap Add Accessory, and select I Don't Have a Code or Cannot Scan.
- Select the Camera you want to pair.
- Enter the Homebridge PIN, this can be found under the QR code in Homebridge UI or your Homebridge logs, alternatively you can select Use Camera and scan the QR code again.
Add the platform in config.json in your home directory inside .homebridge.
For UniFi CloudKey Gen2+ devices, you need to specify the port in the URL to access Protect.
Sample configuration block for UCK Gen2+ devices:
"platforms": [
{
"platform": "Camera-UniFi-Protect",
"name": "UniFi Protect",
"controllers": [
{
"url": "https://my-cloud-key:7443",
"username": "some-unifi-protect-user (or create a new one just for homebridge)",
"password": "some-password"
}
]
}
]For UnifiOS devices like UDM-Pro, UniFi NVR, do not specify the port. You can use your Ubiquiti account credentials, though 2FA is not currently supported. I strongly recommend creating a local user just for Homebridge instead of using this option.
Here's a sample configuration block for UnifiOS devices:
"platforms": [
{
"platform": "Camera-UniFi-Protect",
"name": "UniFi Protect",
"controllers": [
{
"url": "https://my-udm-pro",
"username": "some-unifi-protect-user (or create a new one just for homebridge)",
"password": "some-password"
}
]
}
]This step is not required. For those that prefer to tailor the defaults to their liking, here are the supported parameters.
"platforms": [
{
"platform": "Camera-UniFi-Protect",
"name": "UniFi Protect",
"videoProcessor" : "/usr/local/bin/ffmpeg",
"debug" : no,
"controllers": [
{
"url": "https://my-cloud-key:7443",
"username": "some-homebridge-user (or create a new one just for homebridge)",
"password": "some-password"
}
],
"videoConfig": {
"sourcePrefix": "-re -rtsp_transport http",
"additionalCommandline": "-preset slow -profile:v high -level 4.2 -x264-params intra-refresh=1:bframes=0",
"mapaudio": "0:0",
"mapvideo": "0:1",
"maxStreams": 4,
"maxWidth": 1920,
"maxHeight": 1080,
"maxFPS": 20
}
}
]
| Fields | Description | Default | Required |
|---|---|---|---|
| platform | Must always be Camera-UniFi-Protect. |
Yes | |
| name | For logging purposes. | No | |
| videoProcessor | Specify path of ffmpeg or avconv. | "ffmpeg" | No |
| debug | Enable additional debug logging. | no | No |
| url | URL for UniFi CloudKey G2+ | Yes | |
| username | Your UniFi Protect username. | Yes | |
| password | Your UniFi Protect password. | Yes | |
| sourcePrefix | Prefix to apply to ffmpeg source command. | "-re -rtsp_transport http" | No |
| additionalCommandline | Additional parameters to pass ffmpeg to render video. | "-preset slow -profile:v high -level 4.2 -x264-params intra-refresh=1:bframes=0" | No |
| mapaudio | Mapping of audio channels for ffmpeg. | "0:0" | No |
| mapvideo | Mapping of video channels for ffmpeg. | "0:1" | No |
| maxStreams | Maximum number of streams allowed for a camera. | 4 | No |
| maxWidth | Maximum width of a video stream allowed. | 1920 | No |
| maxHeight | Maximum height of a video stream allowed. | 1080 | No |
| maxFPS | Maximum framerate for a video stream. | 20 | No |