Ubiquiti Unifi Protect cameras

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

Slightly off-topic from Protect, but I'm curious if you have, or have seen, any development for pulling status from UniFi switches and APs for dashboard status with the new CK version? Maybe also support status for "new firmware available?"

I wrote a driver for UniFi networking controllers that supports both OS types on the controller side (UniFi and other): GitHub - tomwpublic/hubitat_unifiEvents

It runs native to Hubitat, no external script required. You can also install from HPM.

I focused on supporting status and events for clients (in my case, cell phones and the like). But if it works for you I could easily add information for devices (like APs and managed switches).

Want to give it a shot?

4 Likes

loving the integration!

one question though...

is it possible at all to add smart detect triggering? and not just motion? @Bago may be able to answer better.

I've been playing around with that. So far, no.

I'm sure you are aware of why I want to do this.

The BS geo location in Protect is useless!

1 Like

I was able to get it working thanks to testing help from @Bago and @markbellkosel84. Thanks guys!

Smart Detect support is in version 1.1 on HPM. Smart Detect has to be supported by the camera and also configured in the UniFi Protect controller.

1 Like

From what I understand smart detection is one of the differences between G3 and G4 cameras

1 Like

I just added LCD message support for the doorbell device (via Hubitat's native Notification driver capability type). This is updated on GitHub, and I bumped the version in my HPM repo for anyone who prefers to update that way.

2 Likes

just a curiosity, does HE just not have enough horsepower to do all of the decoding internally, or is it missing the necessary function(s) (the python server looks like it's just decoding and decompressing the call)?

1 Like