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

Hmm… I tried the auto-discovery. Unfortunately no cameras where found.

This is my NVR setup:

Hard to tell. The binding discovers the cameras by looking at what the NVR returns in the bootstrap json response.
If you enable debug you will get a lot of information.
Look at the lines:
[otect.internal.model.UniFiProtectNvr] - Json:

The Json is the bootstrap and should contain your cameras with ip nr.
Please post the boostrap and I can have a look.

Br S

My Protect installation upgraded to 1.19 (final) yesterday and Openhab is unavailable again. Seems there is another issue again. Can you please check to see if there is another issue with your plugin and the new Protect version?

Will check and report back.

Best regards S

After restarting Openhab it now seems to be working ok.
I was back on protect 1.18 (due to some unifi issues not related to your plugin) before and maybe the automatic update switching to 1.19 while your add-on was already running caused some issues.

I’ve also noticed this today, it completely kills OH with out of memory errors with 1.19

[264.105s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: stacksize: 320k, guardsize: 0k, detached.
Exception in thread “OH-discovery-2” java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
at java.base/java.lang.Thread.start0(Native Method)
at java.base/java.lang.Thread.start(Thread.java:798)
at java.base/java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:937)
at java.base/java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:1005)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)

I’ve been running on my prod system with 1.19 beta without a restart for a month at least without problems. I will update to 1.19 stable and see if there are any differences.
The error you have there seems to be related to discovery, are you doing any thing special when you get it?

Regards, S

And a quick report back, I’ve updated to 1.19 stable and firmware 2.2.5.
So far so good. Try and use the ALPHA15 I built today (although ALPHA14 should work).

After the initial hiccup when my protect system automatically upgraded to 1.19 stable the OOM problems are gone on my system.

I had another issue yesterday, where the binding reported online for my cameras and protect thing but it wouldn’t receive any new events.

I will keep looking for this and report back if it happens again.

This is an error I’m seeing on a14 and a15.

021-08-26 17:04:59.823 [ERROR] [otect.internal.model.UniFiProtectNvr] - Could not find any valid user. Looking for: openhab
2021-08-26 17:05:00.019 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception: 
java.lang.NullPointerException: null
	at org.openhab.binding.unifiprotect.internal.thing.UniFiProtectNvrThingHandler.refreshChannel(UniFiProtectNvrThingHandler.java:306) ~[?:?]
	at org.openhab.binding.unifiprotect.internal.thing.UniFiProtectNvrThingHandler.refreshNvrChannels(UniFiProtectNvrThingHandler.java:226) ~[?:?]
	at org.openhab.binding.unifiprotect.internal.thing.UniFiProtectNvrThingHandler.refresh(UniFiProtectNvrThingHandler.java:204) ~[?:?]
	at org.openhab.binding.unifiprotect.internal.thing.UniFiProtectNvrThingHandler.run(UniFiProtectNvrThingHandler.java:166) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:829) [?:?]

The user “openhab” is configured on the protect side and everything seems to be working ok.

I’ll fix that npe, sloppy coding. However not sure what the root cause is for the user not being set. If I can’t reproduce we might have to look at your bootstrap json to get clues why the user is null.

I’ve built a new version that hopefully handles the above exception.

Regards s

Thanks, S. I will try the new update.

One thing I just found out: Currently I have no issues with memory leaks while normally running your add-on, but as soon as I stop my protect installation using the CK2+ UI the memory usage of OH goes through the roof. Maybe you can take a look into the error handling when the connection to protect breaks after it has been working for a while.

2021-08-31 09:18:19.458 [ERROR] [websocket.UniFiProtectEventWebSocket] - Failed to decode frame, not enough byte: 2
2021-08-31 09:18:19.530 [ERROR] [websocket.UniFiProtectEventWebSocket] - Failed to decode frame, not enough byte: 2

This error goes on and on and on…

I’ll have a look, probably possible to reinitialize the websocket better.

I’ve done a fix now in ALPHA17, please have a look.

BR S

Sorry, Seaside. No Change while using Alpha17. The error message and the increase in memory usage is still existing when I stop protect using the CK+ UI.

Are you sure you are using ALPHA17?
I’ve also added a limit on reinitialization, so it should only try to reconnect every 10 seconds
this is how my log looks:

2021-09-07 21:41:46.157 [INFO ] [ernal.event.UniFiProtectEventManager] - Socket failed, reinitializing!
2021-09-07 21:41:46.291 [ERROR] [websocket.UniFiProtectEventWebSocket] - Failed to decode frame, not enough
 byte: 2
2021-09-07 21:41:56.297 [INFO ] [ernal.event.UniFiProtectEventManager] - Socket failed, reinitializing!
2021-09-07 21:41:56.415 [ERROR] [websocket.UniFiProtectEventWebSocket] - Failed to decode frame, not enough byte: 2

So you should have a failed every 10 seconds until it manage to connect again.

bundle:list showed two versions of your binding installed.

I have cleaned cache and tmp and restarted openhab and now only one is showing up.

And now it is working as you have described.
Thanks

1 Like

I’m seeing the same issue.

Binding installed
345 x Active x 80 x 3.0.0.202109011104 x openHAB Add-ons :: Bundles :: Unifi Protect Binding

Log (repeats):
2021-09-14 18:28:26.293 [INFO ] [ernal.event.UniFiProtectEventManager] - Socket failed, reinitializing!

Connection to CloudKey seems fine but cameras are not updating, e.g “last seen” etc are just blank.

I did two steps mentioned above, checked so I only had one binding and then cleared tmp+cache.

Update:
Updated to 1.19 and added via automatic discovery rather than manually in OpenHAB, now the issue seems gone fortunately :slight_smile:

1 Like

@Seaside When you get the time, I have one issue to troubleshoot and one change request

I still have the message “Could not find any valid user. Looking for: openhab” in my openhab.log all the time. What can I do to further troubleshoot this?

My change request is regarding the message:“Getting Anon snapshot for camera: Haustür, ip: XX.XX.XX.XX”. Could you please change this from info to debug? I use anonymous snapshots a lot and this fills up my openhab.log.

Thanks in advance