Ubiquiti Unifi Protect cameras

I don’t see false motions either. I switched to Smart Detect only. Now I see less of the motions that don’t matter.

Think I have this running right but I'm getting this error in the logs

I have the python script running on a pi and double-checked I was running python 3. Thanks for the help

Your IP address looks like it may be entered incorrectly. Will you check the configuration entry for that? @smwein

Thank you for that. I didn't even notice that.

Thanks

1 Like

Thanks for the help earlier. Not I'm having issue with pm2 it keeps error saying Script not found /Protect/server.py. Have the file in a folder called Protect

Try running it first as node /Protect/server.py to see if you can get a more verbose error message.

Another wild guess... are you absolutely sure that the path is correct? Try this:

ls -l /Protect

When I run ls -l /Protect?

ls: cannot access '/Protect': No such file or directory

but when do cd /Protect it takes me to the folder then I can ./server.py 2112 and everything works

Thanks

I figured it out. I had the wrong folder path.

1 Like

In case it's useful to anyone, a pretty basic systemd service to run the python server script.

Requires a Linux OS using systemd.

  • adjust paths in ExecStart
  • save as protect_service.service
  • copy to /lib/systemd/system
  • systemctl daemon-reload
  • systemctl enable protect_service
  • systemctl start protect_service

[Unit]
Description=Hubitat Protect Server Helper

[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/local/bin/server.py

[Install]
WantedBy=multi-user.target

Not sure what capabilities there are to control cameras via the API, but sure would be nice to be able to changing whether or not a given camera is recording via Hubitat. I have a couple of indoor cameras that I've just accepted fate to leave always recording, but would be nice to disable recording while home and only enable based on hubitat presence.

2 Likes

So I've been battling the UDMP controller crashing (gotta love it) on me and I'm noticing, some associated issues with this driver. The controller device drops into an error state and then appears to never try connecting again. The device ends up with no scheduled events that would reestablish connectivity.

There is the reinitialize method, that seems like its purpose would be to solve this issue. Given the connection would just stop responding/time out/not close gracefully, I'm guessing one of the methods is dropping into an error state and is not configured to call that reinitialize method to help reestablish connectivity.

Edit: I'll have to wait for it to crash again so I can actually fully trace the code flow, but I think a reinitialize() might just need to be added to initialize, inside of the catch. I think an exception is getting caught in refreshCookie, that method is then throwing an exception, back to initialize, which then bombs out to the catch. That catch only sends the error status and then never tries connecting again. So adding a reinitialize, should help to ensure it continues to try to connect until successful.

1 Like

That sequence of events seems plausible, and I agree that your proposed fix makes sense. Thanks for tracking it down.

Backstory: before I had the reinitialize method with its logic to back off from retrying too aggressively, it was easy to get in an infinite initialize loop by doing it the way you described. So instead I just considered a failed initialize as a fatal error for the user to manually resolve.

Please make that change to use reinitialize in your local installation and do a little bit of stress testing to verify that it works as expected.

1 Like

Controller crashed again tonight and the change I referenced above seems to have done the trick to make sure the connection is re-established on failure.

Things otherwise have been working fine for the past 2 days and I haven’t seen anything spiral out of control yet.

1 Like

Awesome, thanks for the feedback.

I made that change in version 1.2.4, now on Github and updated in my HPM listing.

2 Likes

I got doorbell push working, but somehow motion detection is not triggering.

If I manually click the activate motion, the Basic rule using it works fine. I've turned on Debug on Device (but only available on UniFi Protect Controller level, not on the Motion).

Looking at the log, I do not see any motion activation/detection triggered. This is actually true for G3 Flex camera as well.

My UniFi Protect controller is the latest, 1.18.

Any suggestion where I could start?

P.S. I get notification on official UniFi App and other home automation platform like Home Assistant.

I'm not sure where it may be breaking down. I'll PM you with some requests to pull debug logs so that we can start to track it down.

Thanks this was really helpful :slight_smile:

1 Like

I’m actually running into the same thing now. Button presses on the doorbell are triggering events, but the state change to motion active is not. Happy to send any logs as needed to help.

@shaun.rockett, the other poster's issue ultimately ended up being that the python script was not running reliably. After we fixed that all worked as expected.

Can you clarify what you're seeing exactly? It sounds like the motion attribute is changing to active in Hubitat, unless I misunderstood. Do you have any other cameras than the doorbell, and if so do they work correctly with motion?

My apologies. It seems to be working fine now after a reboot of the Hubitat.

Thanks for the follow up!

1 Like