[PROJECT] Driver for Unifi Protect Controllers

i found it.. thanks for the info

when i test this. i get

  • motion : active
  • smartDetectType : waiting

i would think i should get something like

  • motion : active
  • smartDetectType : person

Sorry, forgot to reply before. I do not do any editing of the smartDetectType values returned by the Protect API... so that "waiting" is what it provided.

I checked the Ubiquiti forum and found out that it can return "waiting" if the camera has not completed analyzing the data. Here is what their "Unifi GPT" gave me when I asked:
What does it mean when a camera returns a smartDetection value of "waiting"?

UniFi GPT:
When a camera returns a smartDetection value of "waiting," it typically means that the camera is in the process of analyzing the footage to determine if there is a valid detection. This status indicates that the AI-powered detection system is still processing the data and has not yet reached a conclusion.

i was not using your drives. i removed all the previous protect drivers and installed the ones you listed. i created the virtual device but it fails login. i switched the port from 7443 to 443 and the type to other unifi controllers. that got rid of the connection error i was getting.


I've since removed all the drivers and gone back to [UniFi Controller Manager]. This is the only thing that allows me to log in and get any kind of data from protect. now that i have re-installed it the * smartDetectType : waiting is working

I have a G4 Instant and it doesn't seem to show any of the SartDetectType info. It looks like the value * ExtendedAIFeatures : [smartDetectTypes:[]] doesn't show any additional items though I see 3 in the Protect UI. Person is one of them. Do you know if this is just not something working through this route?

@john66public: I am not familiar with the Unifi Controller Manager. I even searched for it but did not find a thread to any project for it here in the forum. As for the login, you solved that one it sounds. There are a variety of Unifi controllers and sometimes they require a different setting to work (and sometimes it varies by the firmware on the controller as well). So I tried to make the drivers flexible to work with them all.

@mavrrick58: Are you talking about with my drivers or are you responding to @john66public's "waiting" value when using the other one? Or are you having an issue with mine at the moment? From what I can test, mine seems to be working with my G5 PTZ (it detected a person when I went down to the basement to deal with trash a bit ago), but that is the only AI-capable camera I have...

its in the HPM by tomw

I am referring to your driver. I don't even know if it should work. It is a G4 Instant which isn't a super powerful camera. That said it does have support to recognize People, Cars, or Animals. Here is the setup option in Protect.
image

I am using the regular camera driver though "UnifiProtectChild-Camera"


What concerns me is the last item in that screen shot. Was this added recently and maybe it just came in with old data?

Yes, this was very recently added as I saw it in some of the Debug logs I regularly check in case Ubiquiti adds new data reporting in that I do not already have recognition for.

I cannot tell you what it actually DOES though. I saw the log entry, thought it MIGHT be useful so put it as a State Variable (not an Event) until I determine it has no value or it should become an Event. I am not manipulating the value for the field at all. What is listed in there is what the API provides. On my cameras, I have the exact same information as yours, including on the G3 Instant that is not supposed to have any AI. My G5 PTZ (which definitely does, and regularly provides values for smartDetectType) is the same as well... so it does not appear to be what the camera is set for.

My current theory is it might be a placeholder area for when they add additional AI features in.

Ah! Tom and I regularly share information back and forth but I do not use his drivers. I knew he had one for Protect but I had thought it was named more specifically. Have to keep that in mind.

I also do not use HPM... so not surprised I missed it there.

I'm still having issues. even though i have no errors with his drivers. the things i want don't work and there is next to no logging.

after re installing it i now see the smartDeviceType change when i walk in front of the camera but the rules don't work. so i went to the logs to see if the word person was surrounded by something more but there are no logs that i can see.

if i could get your drivers working i would be willing to try but i never got past creating the virtual device. it failed login. i dont know if this matters but im using a Ubiquiti NVR

ive noticed when i install your drivers and create the virtual device. 2 of them show up with the same name. is that expected?

the duplicate device appears to only happen if you name the device UnifiProtectAPI.
I now have auth key successful but still have a WebSock Status Error.

I don't see any cameras. Do i have to manually add them? in the tomw driver it found them and added them automatically.

If my driver is working properly, it will add child devices automatically when it does a refresh. The only device you need to add is the parent device.

I have never tried naming one UnifiProtectAPI... so I will schedule that as something to try over the weekend but I cannot think of how that will add a duplicate as the only devices it adds are child devices (per above).

As for login errors... couple things to try:

  1. Since you have a Ubiquiti NVR, the "Unifi Controller Type" Preference should probably be "Other Unifi Controllers". Once that is saved, the Port # should be either 7443 (usually older firmware) or 443 (newer firmware).
  2. Make sure you have a LOCAL user account with admin rights that you are entering for it. It will not work if it is a cloud user account using MFA.

As a note: With my drivers, you can always delete a child device and the parent will recreate them when there is data for them. You can also delete the parent device and it will delete all children along with it. The only downside to deleting devices is if you have a lot of Rules set up to use them, it can be annoying to switch.

So as i mentioned above I have a G4 Instant only. At one point ealier i did try to add a Third-Party camera which failed to adopt. Since then ever so often i get a unnamed disconnected camera added to my hub. I think Unifi has it partially included. Is there anyway to prevent the Auto Add of devices?

I'm getting there. I have to have webSocket disable, Unifi dream machine selected. other settings throw authentication and connection errors.

Once i set that i seen the cameras get detected in the logs.

On the doorbell device when i hit refresh i get this error
dev:2882024-10-24 11:21:25.210 PMerrorNVR Controller - Page not found for GetDoorbellStatus

@mavrrick58: Sorry, I have trouble keeping who has what in mind. The other camera appearing could be what you are thinking... but I would have to see some logs to check. I do not have a way to prevent the auto-creation of child devices on my Protect driver. When I went to add one of my 3rd party cameras it took QUITE a while... I think I basically gave up and tried again... but I cannot remember now. The second was easier, I remember that for sure. If you leave that child device in there, does it cause any trouble?

@john66public: It appears that the doorbells status URL no longer works. Even I get an error (I do not HAVE any) about the base level of it not being found. Cameras, Bridges, Lights... others still work. So I will have to remove this particular one.

Updated Version(s):

  • UnifiProtectChild-Doorbell.groovy = 0.1.12

Change(s):

  • Changed the refresh to attempt a Camera status data pull rather than the Doorbell one as the doorbell URL no longer seems to work in current Unifi controller software. Not exactly sure when this change would have occurred on the controller as I do not have a doorbell myself.

I updated the driver.
im still not seeing any benefit to this driver for the doorbell. the motion says inactive even when there is motion. and i don't see any smartDetectTypes
i do see * ExtendedAIFeatures : [smartDetectTypes:[]] but it never changes.
i dont see any protect logs at all.
if i delete the doorbell it does come back
dev:3242024-10-25 07:16:23.664 PMinfoDoorbell ffffffff - Updated

dev:3242024-10-25 07:16:23.607 PMinfoDoorbell ffffffff - Installed

  • ButtonPresses : 1
  • Dark : true
  • Device Status :CONNECTED
  • DriverName :UnifiProtectChild-Doorbell
  • DriverVersion :0.1.12
  • Motion Events Today :8
  • motion : inactive
  • numberOfButtons : 1
  • released : 1
  • pushed : 1

State Variables

  • Firmware Version : 4.72.38
  • ThirdPartyCameraInfo : [rtspUrl:null, port:null, rtspUrlLQ:null, snapshotUrl:null]
  • Waterproof_Case : false
  • Platform : s5l
  • DriverName : UnifiProtectChild-Doorbell
  • Device Status : CONNECTED
  • TiltLimitsOfPrivacyZones : {side=bottom, limit=0}
  • CurrentResolution : HD
  • SupportedScalingResolutions : [HD]
  • ThirdPartyCamera : false
  • 4K : false
  • DisplayName : Doorbell
  • 2K : false
  • Hardware Revision : 21
  • Shortcuts : []
  • ID : #############
  • FirmwareUpdateState : Up To Date
  • presence : present
  • MaxPresses : 4
  • RecordingSchedules : []
  • motion : inactive
  • Uptime : 0 Days 7 Hours 26 Minutes
  • Alarms : {motorOverheated=false, lensThermal=0, tiltThermal=0, autoTrackingThermalThresholdReached=false, panTiltMotorFaults=[], lensThermalThresholdReached=false}
  • Motion Events Today : 8
  • Homekit_Settings : {microphoneMuted=false, streamInProgress=false, talkbackSettingsActive=false, speakerMuted=false}
  • NVR_MAC : FFFFFFFFF
  • VideoCodec : h264
  • ExtendedAIFeatures : [smartDetectTypes:[]]
  • MAC : fffffffffffff
  • LastWSSID : ##########
  • Last_Disconnect : Fri Oct 25 12:33:26 EDT 2024
  • numberOfButtons : 1
  • ButtonPresses : 0
  • Type : UVC G4 Doorbell
  • HasRecordings : true
  • DriverVersion : 0.1.12
  • Dark : true
  • StreamingChannels : []
  • DeviceName : Doorbell

Current States

  • DriverName :UnifiProtectAPI
  • DriverStatus : Up to date
  • DriverVersion :0.2.41

State Variables

  • Status : Auth Key successful.
  • Cookie : TOKEN=##########
  • LastWSSAction : smartDetectType
  • Last Refresh : 2024-10-25T23:59:24+0000
  • WebSocket Delay : 1
  • Auth Key : ############
  • DriverName : UnifiProtectAPI
  • LoginRetries : 0
  • Last Login : 2024-10-26T00:00:59+0000
  • LastWSSID : ###########
  • DriverVersion : 0.2.41
  • WebSocket Open : open
  • Last Updated ID : ###########
  • WebSocket Status : OK
  • DriverStatus :
  • CSRF : ############
  • WebSocket Failures : 0