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

iPhones tend to dissconnect Wifi AP while sleeping so there is a misleading “not connected” state but they’re still at home. There is no battery save options on device to disble it while android has this. There is a workaround pinging them with LAN binding but in this case you need to handle “dual” presence detection (one from unifi binding (not protect!) and one from LAN binding). So it is a bit of hassle.

Maybe use the iCloud binding? Or if the polling of that drains the phone battery, use a home automation on the phone to trigger a switch in openHAB.

Sure, why not. I could try and implement it when I get some spare time (sort of random). How do you intend to use it?
Channel for the nvr with all away? Or map certain users? Do you want to trigger a channel on the specific camera for the notification?

Hi @Seaside!

Thank you for your reply. The main purpose would be to detect each users defined on Unifi UDM that is away or inside the perimeter (I have all users for Doorbell Ringing added already). The app on the mobile works great and can be used with Tasker to intercept Geofence notifications but it would be more convenient to have that inside openHAB and not to install Tasker and setup rules for every phone in family.

Thank you.

Hmm, isn’t it true that geofencing in Unifi Protect does not work reliable at all? At least it is this what I can read in a lot of forums.

I haven’t searched about this as I don’t have an issue. This might be related to phone setups like app battery optimization and permission settings. But I’m just guessing. I’ll search for that. Can you give me some links to these sources?

https://community.ui.com/questions/Unifi-Protect-IOS-App-shows-away-even-though-Im-home-/8a9f0f51-8929-4379-8b0e-15cbe171bb68?page=1
https://www.reddit.com/r/Ubiquiti/comments/ub1416/unifi_protect_onsiteaway_status/

Those are 2-4 years old. I’ve found this on Reddit. It is 1 year old. Since than there are no complains.
This might be useful: link.

1 Like

@Seaside is there a jar available with containing your last commit? Or can you give some hints for building it?

BTW, I got an iPhone on Monday and so far, the standard Unifi Network online detection works fine. Maybe because I fetch IMAP Emails every 15 minutes, the iPhone never goes into super deep sleep. Or UniFi has fixed the network online detection for iPhones.

I noticed some problems with the last commit. So I have to do some fixing, will not be able to pull anything off until the weekend most likely.

I’ve built a new version which handles re initialization
and socket termination better.
@SimiWest You could test the latest version out and see if it works better.

On Android there is no problem, I am using the geofence feature since around 2 years. In general its working fine, on android you just have to ensure to disable all power saving and battery optimization features for the unifi protect app. In my case i also allowed background data for the app just to ensure reliability. In general geofencing is an OS feature no matter if IOS or Android but there are many settings which can influence reliability.

Thanks @Seaside. Running the new version for 24h now. Until now it’s running fine. I see quite a lot occurences of this messages in my setup:

  • Watch dog Detected no events recieved, reinitializing!
  • Socket failed, reinitializing!

This was also the case with the previous version, but there I was able to watch the number of threads going up constantly. Hundreds of connections to my dream machine were open in parallel.
With the new version this seems to be fixed.

1 Like

Getting a log “Token missing” message when adding the Bridge thing:

023-12-01 14:20:19.204 [ERROR] [al.thing.UniFiProtectNvrThingHandler] - UniFiProtect Offline due to failuer: Token is missing

I installed this binding via the Marketplace. Configured the bridge with the IP address of my UNVR, included my admin username and password. I can ping the UNVR from my OH Server.

My system is as follows:

Platform: Raspberry Pi 4 Model B Rev 1.5
openHAB: 4.0.4 - Release Build
Unifi Protect Binding: 4.0.0.202311251106
Unifi NVR OS: 3.1.16
Unifi Protect: 2.9.42
USG Pro Network: v7.5.187
1-G4 Doorbell Pro
1-G3 Micro
1-UVC G3 Instant
4-G4 Domes

I turned on debug and included the log below:

2023-12-01 14:20:17.691 [INFO ] [otect.internal.model.UniFiProtectNvr] - Initializing the binding, with config: UniFiProtectNvrThingConfig [host=***.***.***.130, username=ds*******,  password=*************, refresh=60, eventsTimePeriodLength=30, thumbnailWidth=640.0, imageFolder=/var/lib/openhab/tmp, g4SnapshotWidth=3840, g4SnapshotHeight=2160, defaultSnapshotWidth=1920, defaultSnapshotHeight=1080, watchDog=true, g4SnapshotWidthAsString=3840, g4SnapshotHeightAsString=2160, defaultSnapshotWidthAsString=1920, defaultSnapshotHeightAsString=1080]
==> /var/log/openhab/events.log <==
2023-12-01 14:20:17.680 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'unifiprotect:nvr:fc98dffa5b' changed from UNINITIALIZED (DISABLED) to INITIALIZING
==> /var/log/openhab/openhab.log <==
2023-12-01 14:20:19.204 [ERROR] [al.thing.UniFiProtectNvrThingHandler] - UniFiProtect Offline due to failuer: Token is missing
==> /var/log/openhab/events.log <==
2023-12-01 14:20:19.206 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'unifiprotect:nvr:fc98dffa5b' changed from INITIALIZING to OFFLINE (COMMUNICATION_ERROR): Token is missing
==> /var/log/openhab/openhab.log <==
2023-12-01 14:20:19.976 [ERROR] [otect.internal.model.UniFiProtectNvr] - Failed to updated Cameras since we can't seem to login status: TOKEN_MISSING

It seems system is looking for the bridge to provide a token in addition to the id and password.

Has anyone seen this error before? Am I missing something I need to set in the bridge configuration? Is my hardware compatible with this binding? Any help would be greatly appreciated.

Hi @dschoepel ,
in my case(s) it always was installed at least two times.
You could check all installed bundles/bindings via openHAB console and run:

bundle:list | grep Protect

output should look something like this if the binding is installed only once:

Try remove the binding via openHAB console:

bundle:uninstall org.openhab.binding.unifiprotect

Now install the binding from source:

bundle:install "https://github.com/seaside1/unifiprotect/releases/download/unifiprotect-4.0.0-v1.2/org.openhab.binding.unifiprotect-4.0.0-latest.jar"

And finally start the binding:

bundle:start org.openhab.binding.unifiprotect

Thanks for the response, Andre. I only have one Protect binding installed, but I did try your suggestion and uninstalled and installed the binding using the link you provided. I am still getting the same “Token Missing” messages.

Well that’s unfortunate…
I guess you did try to restart openHAB or your entire system?
You could also try to create a new thing / bridge and see if the error still appears on that new thing (disable the old first).
But after that, i dont have any more ideas…

Well - i dont know whats happend, but i do get the same problem as you have right now… thats really strange…

FYI - I did restart my system just to be sure, it did not help.

Too bad it is affecting you now too.

Hope @Seaside can offer some insight into what could be done to solve this…