This Homebridge plugin allows you to add your Unifi Protect Cameras (and their Motion Sensors) to Homekit.It adds smart detection by using a machine learning model to detect specific classes of objects in the camera view.
This plugin will automatically discover all the Unifi cameras from your Protect installation, and provide the following sensors for each one it finds:
The plugin uses the Unifi Protect API to get motion events on a per camera basis.When motion has been detected one of the two methods below will be used to generate a motion notification in Homekit:
Before installing this plugin, please make sure all the prerequisites have been met first.Consult the readme and the wiki before proceeding.
In short, the main dependencies are:
sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
brew install pkg-config cairo pango libpng jpeg giflib librsvg
sudo apt install g++
Next, to install this plugin simply type:
sudo npm install homebridge-unifi-protect-camera-motion -g --unsafe-perm=true
Next, open the config.json
that contains your Homebridge configuration, and add a block like the following one to the platforms
array:
{
"platform": "UnifiProtectMotion",
"name": "Unifi protect cameras & motion sensors",
"unifi": {
"controller": "https://protect-ip:controller-ui-port",
"controller_rtsp": "rtsp://protect-ip:controller-rtsp-port",
"username": "username",
"password": "password",
"excluded_cameras": [
"id-of-camera-to-exclude-1",
"id-of-camera-to-exclude-2"
],
"motion_interval": 5000,
"motion_repeat_interval": 30000,
"motion_score": 0,
"enhanced_motion": true,
"enhanced_motion_score": 50,
"enhanced_classes": ["person"],
"enable_motion_trigger": true,
"enable_doorbell_for": [
"id-of-camera-to-act-as-doorbell-1",
"id-of-camera-to-act-as-doorbell-1"
],
"save_snapshot": true,
"debug": false,
"debug_network_traffic": false,
},
"upload_gphotos": false,
"googlePhotos": {
"auth_clientId": "CLIENT-ID",
"auth_clientSecret": "CLIENT-SECRET",
"auth_redirectUrl": "http://localhost:8888/oauth2-callback"
},
"mqtt_enabled": false,
"mqtt": {
"broker": "mqtt://broker-ip",
"username": "MQTT-BROKER-USERNAME",
"password": "MQTT-BROKER-PASSWORD",
"topicPrefix": "motion/cameras"
}
}
You can verify the correctness of your config file by using jsonlint.
The config must be valid or Homebridge will fail to restart correctly.If you are using Homebridge Config X, it will do its best to alert you to any syntax errors it finds.
Field | Type | Required | Default value | Description |
---|---|---|---|---|
platform | string | yes | / | UnifiProtectMotion |
name | string | yes | / | Name of the plugin that shows up in the Homebridge logs |
unifi | object | yes | / | Wrapper object containing the unifi configuration |
upload_gphotos | boolean | no | false | Contains a boolean indicating whether or not to upload each detection to a google photos album. When using enhanced mode the image is annotated with the class/score that was detected. |
mqtt_enabled | boolean | no | false | Set this to true to enable MQTT support. Additional configuration required! |
videoProcessor | string | no | ffmpeg | Contains the path to an custom FFmpeg binary |
Field | Type | Required | Default value | Description |
---|---|---|---|---|
controller | string | yes | / | Contains the URL to the CloudKey or UDM with UnifiOS, or as legacy the URL to the Unifi Protect web UI, including port (no / or /protect/ at the end!) |
controller_rtsp | string | yes | / | Contains the base URL to be used for playing back the RTSP streams, as seen in the RTSP configuration (no / at the end) |
username | string | yes | / | Contains the username that is used to login in the web UI |
password | string | yes | / | Contains the password that is used to login in the web UI |
excluded_cameras | no | string[] | [] | An array that contains the IDs of the cameras which should be excluded from the enumeration in Homekit, all available IDs are printed during startup |
motion_interval | number | yes | / | Contains the interval in milliseconds used to check for motion, a good default is 5000 milliseconds |
motion_repeat_interval | number | no | / | Contains the repeat interval in milliseconds during which new motion events will not be triggered if they belong to the same ongoing motion, a good default is 30000 to 60000 milliseconds. This will prevent a bunch of notifications for events which are longer than the motion_interval! Omit this field to disable this functionality |
motion_score | number | yes | / | Contains the minimum score in % that a motion event has to have to be processed, a good default is 50%, set this to 0 when using enhanced motion! |
enhanced_motion | boolean | yes | / | Enables or disables the enhanced motion & object detection detection with Tensorflow |
enhanced_motion_score | number | sometimes | / | This field is required if the enhanced_motion field is set to true and contains the minimum score/certainty in % the enhanced detection should reach before allowing an motion event to be triggered |
enhanced_classes | string[] | sometimes | [] | This field is required if the enhanced_motion field is set to true and contains an array of classes (in lowercase) of objects to dispatch motion events for. The array should not be empty when using the enhanced detection! Look in look in src/coco/classes.ts for all available classes |
enable_motion_trigger | boolean | no | false | Contains a boolean that when set to true will enable an extra button for each camera to manually trigger a motion notification |
enable_doorbell_for | string[] | no | [] | Contains the id of the cameras for which the doorbell functionality should be enabled, all available IDs are printed during startup |
save_snapshot | boolean | no | false | Contains a boolean indicating whether or not to save each detection to a jpg file in the .homebridge directory. When using enhanced mode the image is annotated with the class/score that was detected. |
debug | boolean | no | false | Contains a boolean indicating whether or not to enable debug logging for the plugin and FFmpeg |
debug_network_traffic | boolean | no | false | Contains a boolean indication whether or not to enable logging of all network requests |
Field | Type | Required | Default value | Description |
---|---|---|---|---|
auth_clientId | string | sometimes | / | This field is required when the upload_gphotos is set to true. Fill in the Client ID you generated for OAuth2 authentication |
auth_clientSecret | string | sometimes | / | This field is required when the upload_gphotos is set to true. Fill in the Client Secret you generated for OAuth2 authentication |
auth_redirectUrl | string | sometimes | / | Fill in 'http://localhost:8888/oauth2-callback' as a default, if you change this value to something else, also change it when creating the OAuth2 credentials! The port should always be 8888! |
To enable the upload to Google Photos functionality please read the relevant wiki article
Field | Type | Required | Default value | Description |
---|---|---|---|---|
broker | string | no | / | This field is required when the enabled field is set to true. Fill in your MQTT broker url, without the port |
username | string | no | / | This field contains the username for the MQTT broker connection, if any |
password | string | no | / | This field contains the password for the MQTT broker connection, if any |
topicPrefix | string | no | / | This field contains the optional topic prefix. Each motion event will be dispatched under topicPrefix/cameraName |
As per 0.4.1 the enumerated cameras and accompanying switches/triggers will show up automatically, You don't need to add them in manually anymore!If you add your Homebridge instance to the Home app the cameras will automatically be there.
If you are upgrading from a pre 0.4.1 the cameras you previously had in the Home app will no longer work and will have to be removed!Tap on a camera preview to open the camera feed, click the settings icon and scroll all the way to the bottom, there select Remove camera from home
.
npm install
in the project root folderresources/test-config/
npm run watch
to automatically watch for changes and restart Homebridge if needed, you can also add a remote debugger on port 4444 to debug the code.npm run homebridge
to start a Homebridge instance that points to the local config that does not auto-reload when changes are saved.A big thanks to the developers of Homebridge Camera FFmpeg and Homebridge-unifi-protect for their contributions and valuable insights in how to get things working!
This plugin is provided free of charge and without any warranty of its functionality.
The creator cannot be held responsible for any damages, missed motion notifications that cause damage or harm.
Homebridge UniFi Protect HomeKit support for the UniFi Protect ecosystem using Homebridge. homebridge-unifi-protect is a Homebridge plugin that provides HomeKit support to the UniFi Protect device eco
Homebridge UniFi Occupancy Sensor This Homebridge plugin will provide an occupancy sensor accessory to HomeKit based on the devices connected to WiFi access points managed by a UniFi Controller. The p
camera.ui camera.ui is a homebridge user interface to control your RTSP capable cameras. It supports almost everything you need for a camera user interface. Live streams on Web Web App with push notif
Homebridge Camera FFmpeg Homebridge Plugin Providing FFmpeg-based Camera Support Installation This plugin is supported under both Homebridge and HOOBS. It is highly recommended that you use either Hom
homebridge-mijia-camera Homebridge plugin for the Xiaomi Mijia 1080P Smart IP Camera, also known as Mi Home Security Camera. For now the plugin only allows turning on and off the camera. Installation
homebridge-website-to-camera Homebridge plugin for displaying a Website (intended for Google Maps-->Traffic) as Camera If you find my work useful you can buy me a coffee, I am very thankful for your s