UniFi Protect Binding (Cloudkey gen2+, Dream Machine Pro, NVR)

UniFi Protect Binding for openHAB


Intergrates UniFi Protect Camera System into openHAB. See UniFi Camera Security - Ubiquiti
This binding utilizes an undocumented json REST API that is present in the NVR.

Documentation / Installation / Download


Any bug you find is good to report. Preferred way of reporting bugs is to create an issue on github: Issues · seaside1/unifiprotect · GitHub
I will look at failures in this thread as well.


Create a Pull Request on github: Pull requests · seaside1/unifiprotect · GitHub




Some screenshots:

Built a new ALPHA2 version which fixes NPEs when downloading snapshots and handles Event Timers a bit differently for dowloading heatmaps and thumbnails.

Would be great if someone would dare to try it out :slight_smile:

I’ve reworked the motion detection. It now has threee items:

Image   G3DMyMotionThumbnail    "G3 Thumbnail Img" (G3DMyCam) { channel="unifiprotect:camera:NVRID:MACADDRESS:motion-thumbnail" } 
Image   G3DMyMotionHeatmap    "G3 Heatmap Img" (G3DMyCam) { channel="unifiprotect:camera:NVRID:MACADDRESS:motion-heatmap" } 
Number  G3DMyMotionScore      "G3 Score [%d]" (G3DMyCam) { channel="unifiprotect:camera:NVRID:MACADDRESS:motion-score" } 

The heatmap and motion event picture are captured automatically now, no need for a manual DSL rule. I’ve also added a score for the image, in order to be able to filter out false positives.

Added and ALPHA3 version with new motion detection.

Good news, CloudKey Gen2 has a beta firmware with UniFiOS. I can implement the event based api over websockets now as well as supporting the other UniFi OS devices (UDMPro and Unifi NVR). Which means the binding won’t have to poll for events.

I’ll get back once it is done.

See here for more info: (You need to be logged in to access the page)

1 Like

I’ve updated the binding to only support UniFi OS now.
If you have a Cloudkey Gen2+, update to firmware 2.0.18 or later.
UDMP and UNVR should work but have not been tested. Would be great if someone could try and test them.


Fixed some bugs and changed event API to not be called as frequent.
Event based API is whats next in line.

New ALPHA6 version. This binding now has implemented the event API over websockets making motion detection instant.

Next up is support for OpenHAB 3.


I’ve added support for OpenHAB 3.0.0.
I have only tested it briefly for OpenHAB 3.0.0M4.
Future versions will only be built for OpenHAB 3.

Great work on this binding and documentation @Seaside
I have implemented binding org.openhab.binding.unifiprotect-2.5.x-ALPHA6.jar on Openhab version - 2.5.9-1
UniFi-CloudKey-Gen2-Plus - firmware version 2.0.22

From openhab I was able to add UniFi Protect NVR and configure. Was then able to add two Unifi Cameras (G3 & G4Doorbell) thru PaperUI. I am seeing all the expected Items and logged events but unable to trigger any rule using these events. Can anyone confirm successful rule trigger from this bindings ItemStateChange logs? I have several other working rules currently in place fyi.

2020-12-02 16:37:10.064 [vent.ItemStateChangedEvent] - unifiprotect_camera_3e2f3681_E063DAAF6BD1_is_motion_detected changed from OFF to ON

rule “Front of House Motion”
Item unifiprotect_camera_3e2f3681_E063DAAF6BD1_is_motion_detected changed to ON
//triggering light on event
//triggering logInfo
//triggering sendMail action

Hi James, could you please put some step-by-step instruction what to do to let the binding work with the cloud key. I have the cloud-key-gen2+ - the latest firmware I could find and which is installed is the 1.1.13. I downloaded the jar file and put it in the addon-folder - but I could not see any binding in the paper UI panel. Any tips or hints for me?

Thanks in advance!

Is the camera that you are trying to motion detect the G4 Doorbell?
I have not added support for doorbell yet, but might still work. If it’s the G4 Doorbell, please try the other camera and see if that one works.

Looks good to me, OpenHab is registering it as an event.
Try changing the rule to something like this and when reloading the rule pay attention for error messages:

rule "Front of House Motion"
  Item unifiprotect_camera_3e2f3681_E063DAAF6BD1_is_motion_detected changed to ON
        logInfo("UniFiProtect","Motion detected ON by UniFiProtect Hello World!")

Then look in the openhab.log for the logInfo line.

I will add some screenshots from PaperUI, but otherwise my first post should be pretty much step by step.

You need beta firmware at least 2.0.18 for it to work.
See: https://community.ui.com/releases/UniFi-Cloud-Key-Firmware-2-0-22/2ba23601-5300-45fa-bd8d-a00ff13bd7b6
You need to be logged with your ubiquiti account in order to be able to see the post and download the beta firmware.

That should be enough you will then be able to add a new Thing using the binding, I’ll attach some screen shots to the original post. You still need a newer firmware to be able to use the binding though. Please take a look in the openhab.log if you see any errors.

Regards, S

OH2 PaperUI Setup:

Add new thing as per below:

Select correct binding

Select to add a nvr manually (bridge)

Cameras should be able to be discovered without manually adding them:

First - Thanks a lot seaside!
It seams, that the binding isn’t installed correctly - I do not the the expected binding while adding a thing.

Is there anything more to do than downloading the jar-file and put it in the addon-folder (/usr/share/openhab2/addons) / modifying rights or any other file or configuration?

You can do

chmod a+rx /usr/share/openhab2/addons/org.openhab.binding.unifiprotect-2.5.x-ALPHA6.jar

Also do

ls -l /usr/share/openhab2/addons/ 

to verify permissions.

You can also verify using karaf console to see if the binding is installed:

openhab> bundle:list |grep -i "unifi"                                                                                                  
203 │ Active │  80 │      │ openHAB Add-ons :: Bundles :: Unifi Protect Binding

Rights of the jar file is all fine. What I get in the karaf console is the already installed UniFi Binding but the Protect Binding is still missing…
265 x Active x 80 x 2.5.10 x openHAB Add-ons :: Bundles :: UniFi Binding

Or do I have do deinstall the UniFi Binding???

No you don’t have to uninstall the unifi binding, they run fine side by side.

Verify the file size on the jar file, and also restart openhab and look for any error messages in the log.
The size for me on an rpi4 with 32 bit openhabian is 124675 bytes.

I’m running the binding on openhab 2.5.10 and I have tested it on 2.5.7, 8, 9 and 10.

ok, the size of my file is 90.820 bytes !? I downloaded the file from https://github.com/seaside1/unifiprotect/blob/main/bin/org.openhab.binding.unifiprotect-2.5.x-ALPHA6.jar
I’m running openhab 2.5.10 as well.