Ubiquiti Unifi Protect cameras

What are you using for the NVR? The cloud key, UDMP, or NVR, NVR Pro?

@Bago I'm using the Cloud Key v2

Thanks. I tried it with the NVR, but it can't login. I'll mess around with it if (when) I get some time.

1 Like

Let me know if you get it working. I am not so good at coding either.

FYI - I'm running the new Cloud Key firmware (v2) and the assigned port usage per controller is gone. It's likely that once you upgrade whatever is working will break.

I wrote a new UniFi Protect driver to provide camera, chime, doorbell, light, and viewport functionality.

I added it to HPM (search for "unifiprotect"). Here's the code:

There are many more features that could be supported, so let me know if you have any requests.

5 Likes

Wanted to drop the note that I've been testing this with my UI Protect setup and its working great. I haven't done much with rules, but the polling works fine. I'm running the http script on one of my RPis.

1 Like

Thanks again for your help with testing, @jhciotti!

Just wanted to mention that this doesn't do polling for status and state (other than once at startup) but rather uses the websocket events for all updates. So, it will work for motion and doorbell press events only if the external script is running. @Bago figured out the special sauce to get it running automatically in a Node.js (like RPi) environment.

1 Like

Sounds like a job for Home Assistant. https://www.youtube.com/watch?v=JdW14cKp43U if your not interested in HA you can still see how he gets the stream info from the unifi cams.

I have been laying the groundwork for a Unifi Protect setup for some time now and have a G4 Doorbell coming tomorrow. My current doorbell situation is an Aeotec Siren 6 with the button add on.

If I understand this correctly, your driver will allow me pick up the G4 button being pressed in Hubitat which can then trigger the Siren 6 tone of choice. Is this correct?

I have a RPi that would be perfect for this but my pi skills are very very lacking.

Fairly straightforward to install the necessities on the pi?

Yes, this will observe button presses on the doorbell and motion on any cameras (including the doorbell?) that are supported. Then you can use those events to do whatever you like in Rule Machine or whatever other app.

The Pi setup is pretty simple. Assuming you are running Raspberry Pi OS (aka Raspbian):

Navigate to the directory you want to run it from, then get the script from GitHub:
wget https://raw.githubusercontent.com/tomwpublic/hubitat_unifiProtect/main/server.py

Make the script executable:
sudo chmod +x server.py

Run it (for testing):
./server.py or python3 server.py (the latter may be necessary if you have multiple versions of python installed)

On the Hubitat side, initialize the driver by executing Initialize on your UniFi Protect Controller virtual device.

Create child devices by executing createChildDevice on your UniFi Protect Controller.

If all went as expected up to this point, you should have a child doorbell device and the events will start coming through.

If all of that works, you'll want to set the script to run automatically on the Pi. There are a bunch of ways to do this, but I like pm2:

wget -qO- https://getpm2.com/install.sh | bash (if you don't already have pm2 or node.js installed)
pm2 startup (then copy/paste and execute the command that it prints out)
pm2 start server.py
pm2 save
pm2 list (to confirm that the server script is running as expected

I think that's it. @Bago got it running from scratch. Did I miss anything?

EDIT: made a couple of corrections to avoid confusion. Also, see this post for a useful tip if you're fighting Python version ambiguity.

3 Likes

@markbellkosel84

This requires Python 3, so you need that installed. You can check the version by:
python --version

If it says less than 3, then install the newer version:
sudo apt install python3

After installing, check the version again to verify that it is the default.
If it's not the default, you can change the default by:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1

2 Likes

I'm getting stuck at the "Run it" portion.

pi@raspberrypi:~ $ python3 server.py
INFO:root:Starting httpd...

does this mean it's working? It just seems to sit there.

If I proceed into Hubitat I fill everything out and click initialize but I get commStatus: unknown which then changes to commStatus: error

Yes, that print showing up on the console means that the server is running.

Please PM me a screenshot of your device configuration page in Hubitat. Are you sure that the IP addresses are correct for your UniFi Protect controller and the Pi server (which should certainly be different)? Also, please PM me an output of the debug log in Hubitat (just open Logs in another window or tab) starting from Initialize.

It seems that I am getting some kind of IP issues. Tomw suggested that I reach out to you since you have real world experience with this set up in Unifi Protect.

This what I am getting in Hubitat when I try to initialize

2 Likes

Sent you a PM

1 Like

@Bago helped out a ton and @markbellkosel84 is up and running. There were at least three issues:

  • The script requires Python3. You need to install and may need to tweak your configuration to make that the default Python version on the Pi.
  • Hubitat, the UniFi controller, and the Pi all apparently need to be on the same VLAN (or otherwise routable to each other).
  • The credentials on the device page should be the ones for the UniFi controller, not the Pi. It's ambiguous, so just putting this here for clarity.
3 Likes

looks like my next step is making a new rule in Unifi for my hub to be able to talk to my controller

1 Like

Can this also be used to trigger an action like a siren tone for the unifi access pro system doorbell function too? I have the unifi access installed for access control, and it has a doorbell function, but I'd like to have a way to trigger an actual bell or something instead of just phone notification.

I'm not familiar with UniFi Access, but it looks like yet another ecosystem from Ubiquiti. I use UniFi networking and wifi (not sure if this has a specific marketing name) and this thread is about UniFi Protect.

It looks like the same dev that made the homebridge UniFi Protect integration (which I based my Hubitat integration on) is considering making a UniFi Access implementation, which could probably be ported to Hubitat when/if it is completed: Update · Issue #1 · hjdhjd/homebridge-unifi-access · GitHub