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

The handler is notified that there is a websocket event happening, these are processed and put into hashmaps, when the code asks for info about the event, we cannot find it in our cache.
I’m not sure this is a bug or not, it could be safe to ignore or could actually be something. I have them as well in my logs, I will see if I can handle this better, if it’s not important I will change logging to debug so it’s not displayed at least.

BR S

Hi guys,
yesterday I updated Unifi OS (v2.2.12), Network (v6.5.53) and Protect (v1.20.0) on my UCKP. Since auto-updates are disabled within Unifi OS I am pretty sure that there were some former updates not installed - just as information.

Since those updates OH3.1.0 is running into OOM issues all the time. Several restarts of OH and Windows lead to a proper running OH for some minutes until RAM gets highloaded and any click on the PC and / or OH Main UI takes several minutes.

Since the updates on my UCKP were the only thing changed, my first assumption was that Unifi binding were causing the issue since Controller thing was offline and showed an error. After a short discussion in Unifi Binding Thread, I could figure out that actually Protect binding (ALPHA17) is causing the OOM issue. After disabling Protect NVR thing as well as all the cams, OH is working fine again.

Is there anybody running with above mentioned versions? Any issue with OH OOM? Or any idea at all?
If you need any information from the logs (e.g.) please let me know. Thanks!

Hi!
I also have a UCKP i’m running fw 2.2.5 and protect 1.19 under openhab 3.2. I have no memory issues. I’ll try to upgrade my UKCP and see if I run into the same problem.

BR S

I have updated to 2.2.12 and 1.20.0 now. No issues so far.
How long does it take before you get oom? Do you mind sharing your rules?
You can also enable debug for the binding, it will produce a lot of logs, but might give a clue as to what is going on.

Br S

FYI: Updated to Unifi Protect 1.20 … no problem anymore

Based on the discussion with pacive it’s an issue of the login procedure. We could find this out for the Unifi binding since it’s not working but at least not crashing whole OH. He mentioned that Unifi binding version for OH 3.2.0.M4 includes a few bug fixes which may resolve the issue. If it’s interesting for you, you can find it here. Since you are also running OH3.2 I guess I will try the OH update to Milestone first.

Regarding your questions:

  • The OOM comes up after a few minutes after (re-) starting OH. I assume that at this time the login happens.
  • I will reactivate protect and set log level to debug.
  • I do not use any rule für UVC, just a few things in a sitemap and habpanel to set some things manually.

Keep you informed!

Edit: I am wondering about the Two-Factor-Authentification - I was pretty sure that enabling this is mandatory since a few month, but I saw that this is disabled in my Unifi account. Might this be sonmehow related to my issue? Did you enable 2FA?

Edit2: after update to OH3.2 everything is working fine again! Thanks for your support! :slight_smile:

Like I said in the UniFi thread, might still be an issue to fix the login, it should probably back off and not be that aggressive.

I agree, even there is any issue, it would be great if OOM could be prevent.

Another thing: I fear I was too quick with my response that everything works fine after updating to OH3.2 :frowning:
Actually all things were online but the cam channels were not working. I did not recognize right away, sorry. I tried to delete / readd cam Things and found followings:

  1. NVR is online and working as long as no cams are added (Last Seen is updated every minute)
  2. NVR is online but not working when a camera is added (Last Seen not updated anymore at the moment when a camera is added)
  3. Channels of cam get not updated and stay NULL (==> 2.)
  4. Channels of cam get updated after restarting OH (most likely once at startup)
  5. NVR is online but Last Seen will be not updated anymore (==> 4.)

I set log level to DEBUG after restarting OH (one camera was added before stoping OH). May I send you the log file @Seaside? All entries not related to Protect binding were deleted, but the log file is still quite heavy, though. And to be honest I am not sure if there are any sensitive data inside, that’s why I prefer a PM instead of posting here.

Regards,
Sascha

Sure you can pm me the logs. Feels like there is some issue with the login. You should look at the bootstrap json.

Best regards s

Send you a PM. Thanks in advance!

Mine was working fine until I updated to Unifi Protect 1.2.0. I also started running into the OOM issues. I’ve disabled the binding for the time being to restore my OH function. I am running 3.2.0.M4,

I was running 3.1.0 when I had the OOM issues which do not occur anymore with 3.2.0. After a restart of OH, how long will it take until you get OOM? If it occur only a few minutes after restart, I guess it is also an issue of login procedure.

I’ll look into it, from your log I can see some things, the login procedure needs to be refactored to be more robust.

I have not seen this issue myself.

Best regards s

The NVR thing is working fine when there is no cam added. When I add a camera as thing the connection of NVR gets lost. Ist there a difference in login when a camera is added or not?

On 3.2.0.M5 with Protect 1.2 get “Socket failed, reinitializing!” error and after 8-20 hr OOM. Had to disabled the binding as it brings down OpenHAB.

All things show online however, when taking a snapshot see this error but the snapshot works:

2021-12-07 10:10:42.351 [INFO ] [l.thing.UniFiProtectBaseThingHandler] - Getting snapshot for camera: Garage walkway, ip: 192.168.xx.xx
2021-12-07 10:10:43.340 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.unifiprotect.internal.thing.UniFiProtectG3CameraThingHandler@2582f003': No enum constant org.openhab.binding.unifiprotect.internal.UniFiProtectRecordingMode.DETECTIONS
java.lang.IllegalArgumentException: No enum constant org.openhab.binding.unifiprotect.internal.UniFiProtectRecordingMode.DETECTIONS

Let me know if I can help.

I have done a fix for OpenHab 3.x support and fixed the renamed recording value.
Let me know if this works.
You might have to remove old cameras and nvrs and readd them. Make sure to use the same id for the nvr, and then you should be able to keep your old items.

Regards, S

Hi Seaside.

I sometimes have the issue, that a person ringing the doorbell does not get detected. From looking at my logs the “IsRinging” Event does not fire, but the “LastRingTime” date changes to a newer value.

2021-12-07 15:20:46.552 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamIsRinging' changed from OFF to ON
2021-12-07 15:20:48.423 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamRingThumbnail' changed from raw type (image/jpeg): 25074 bytes to raw type (image/jpeg): 23403 bytes
2021-12-07 15:20:53.932 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamIsRinging' changed from ON to OFF
2021-12-07 15:21:24.060 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamIsRinging' changed from OFF to ON
2021-12-07 15:21:26.155 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamRingThumbnail' changed from raw type (image/jpeg): 23403 bytes to raw type (image/jpeg): 25917 bytes
2021-12-07 15:21:28.925 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamIsRinging' changed from ON to OFF
2021-12-07 15:21:32.690 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamLastRing' changed from 2021-12-07T12:33:18.397+0100 to 2021-12-07T15:21:23.439+0100
2021-12-07 16:37:15.418 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamRingThumbnail' changed from raw type (image/jpeg): 25917 bytes to raw type (image/jpeg): 22971 bytes
2021-12-07 16:37:15.419 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamIsRinging' changed from OFF to ON
2021-12-07 16:37:18.730 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamIsRinging' changed from ON to OFF
2021-12-07 16:37:39.920 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamLastRing' changed from 2021-12-07T15:21:23.439+0100 to 2021-12-07T16:37:13.188+0100
2021-12-07 17:28:36.797 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamIsRinging' changed from OFF to ON
2021-12-07 17:28:38.791 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamRingThumbnail' changed from raw type (image/jpeg): 22971 bytes to raw type (image/jpeg): 10704 bytes
2021-12-07 17:28:41.817 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamIsRinging' changed from ON to OFF
2021-12-07 17:28:44.158 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamLastRing' changed from 2021-12-07T16:37:13.188+0100 to 2021-12-07T17:28:36.520+0100
2021-12-08 10:58:21.507 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'FrontDoorCamLastRing' changed from 2021-12-07T17:28:36.520+0100 to 2021-12-08T10:58:18.681+0100

here the corresponding openhab.log entries

2021-12-08 10:58:16.301 [ERROR] [al.thing.UniFiProtectNvrThingHandler] - Failed to get event, ignoring: UniFiProtectAction [action=add, modelKey=event, id=61b081b800183403e700186b]
2021-12-08 10:58:16.760 [ERROR] [al.thing.UniFiProtectNvrThingHandler] - Failed to get event, ignoring: UniFiProtectAction [action=add, modelKey=event, id=61b081b802023403e700186c]
2021-12-08 10:58:18.948 [ERROR] [al.thing.UniFiProtectNvrThingHandler] - Failed to get event, ignoring: UniFiProtectAction [action=add, modelKey=event, id=61b081ba02ad3403e700186d]
2021-12-08 10:58:21.959 [WARN ] [otect.internal.model.UniFiProtectNvr] - Heatmap request resulted in a error size image
2021-12-08 10:58:21.989 [WARN ] [otect.internal.model.UniFiProtectNvr] - Heatmap request resulted in a error size image
2021-12-08 10:58:21.990 [ERROR] [l.thing.UniFiProtectBaseThingHandler] - Failed to set heatmap, event type not present: UniFiProtectEvent [type=motion, start=1638957492944, end=null, camera=6109692702802b03e70003ed, score=81, id=61b081b800183403e700186b, metadata=MetaData [objectType=null, objectCoords=null, objectConfidence=null], modelKey=event, partition=null, thumbnail=e-61b081b800183403e700186b, heatmap=e-61b081b800183403e700186b, smartDetectTypes=[], smartDetectEvents=[61b081b802023403e700186c]] or invalid heatmap: null

The last ring at 10:58:18 this morning just came through as a ItemStateChangedEvent for Last Ring. The IsRinging Change from OFF → ON and back is not there. It seems there were some events which could not get handled.

Any idea what that might be?

Thanks in advance,
Chris

The reason why lastRingTime is updated is basically because that info originates from the boostrap.json, which is pulled every minute. The doorbell notification originates from the websocket connection notification. My guess is that some notifications over the websocket is not working correctly for some reason.

I have noticed this myself with my G4 Doorbell. Have you tried the beta2 version?
I have not seen it since i switched and upgraded UniFi Protect to 1.20.0.
Let me know if it’s still an issue on 1.20.0 with the beta2 binding, meanwhile, I’ll also see if it’s an issue for me.

Regards, S

I was already on 1.20 when this happened, but I have upgraded to beta2 after that. I’ll report back.

After a very first check, beta2 seems to solve the issues! Cam’s channels are updated and NVR does not lose the connection after adding a cam / channel. I will setup all channels and all cams at the weekend and come back to you if any problem will occur.

Meanwhile thanks a lot @Seaside!

1 Like