Ubiquiti Unifi Binding Feature Discussion

Correct me if I’m wrong here, but I believe UniFi OS is on all the newer firmware versions. The way I distinguished the UniFi OS on my system was the controller local address changed from 192.168.xxx.xxx:8443 to 192.168.xxx.xxx/network which broke the UniFi binding back in OH2.

The UniFi Protect binding documentation has a short description of the UnFi OS:

Supported hardware

  • UniFi Protect Cloud Key Gen2+ Firmware >= 2.0.18
  • UniFi Dream Machine / Pro
  • Any UniFi Protect Camera G3 and G4
  • UniFi NVR
  • UniFi Doorbell

The binding has been rewritten to support UniFi OS only. That means if you have a UCKP (Cloudkey gen2+)
you need to update it to at least firmware 2.0.18. After 2.0.18 UCKP is running UniFiOs just like the
UDMP and UNVR.

I just updated openHAB from 3.0.1 to 3.1.0.M3 with UniFi controller 6.0.43 (on a CKG2+)

You have a Cloud Key Gen2+. micware was asking about running the Unifi controller on Linux instead - which is what I do too and what seimenb does. So you’re using UniFi OS and need the toggle on but we don’t.

Ah I see, sorry I got things mixed up. I thought the authentication issue applies to all new firmware.

Has this issue been solved? I’m still on OH2.5 and my Ubiquiti Cloud Key 2+ no longer connects since I updated the Unifi software to version 6.0.44. I’ve tried changing the port from 8443 to just 443, but it just gives errors in the log:

Unhandled exception while refreshing the UniFi Controller unifi:controller:a2bc7a83 - com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 12 path $

No, still broken. Even with 3.1

I’ve added this problem as an issue here:

Hi All,

On 2.5.12 and running Unifi OS 6.2.25. I cannot get my Android or Iphone to switch on based off presense. I’m using the binding that comes native with 2.5.12

Any suggestions? Thanks!

Currently, the 2.5 versions of the UniFi binding do not support UnifiOS, so you won’t get it to work (I have the same problem) The controller software is no longer reachable at 192.168.xxx.xxx:8443 but rather 192.168.xxx.xxx/network and unifi changed the auth stuff.

This feature has been implemented in OH3.1M2 though so if someone wanted to back-port the binding, I’d be overjoyed…

1 Like

Thats a real shame :frowning: hopefully someone can back port it!

It works! (@dastrix80)

I’ve gotten the it to work by manually merging the commit that added the UniFi-OS code and then recompiling the UniFi Jars. Here they are:

2.5.13 UniFi binding fix with UniFi OS support

To use these you’ll need to:

  1. Just to be safe, delete the current unifi controller thing
  2. Uninstall the existing unifi binding via Paper UI
  3. Install the jars by placing them in the addons folder (UniFi will show up in the “add thing” menu)
  4. Create the UniFi controller thing and make sure to set the the unifios toggle to true and use the right username/password (NOT ubiquiti account!). Also, make sure you’re on port 443
  5. I was getting weird 404 errors, so I restarted OH and everything started working properly!
3 Likes

THanks! @Marmoset_Threat when you say use the right account? which would that be. The one I login with? Ive tried the various accounts, no joy. I run this in a container on QNAP and its accessible just fine on 8443 using a browser

I can create the thing but its stuck in uninitialized

Also the binding comes up twice on my system, you’ve got SNAPSHOT & sources.jar

When I visit the IP of my cloudkey (CK gen2, running UniFi OS firmware 2.0.27), I’m presented with a menu that lets me enter the UniFi or Protect software. Along with that, there’s Cloudkey Settings and a “Manage Users” option too (xxx.xxx.xxx.xxx/users). Here I created a “Limited Admin” user (I called mine “openhab_access”) that has read-only permissions for UniFi and this is the user that I put in the Thing config for the UniFi Controller in OH.

As for the duplication thing, I just included both jars because I’m unsure which is needed. Maybe only one of them works and I got lucky using the right one?

fair enough, doesnt work with both or either for me

Very strange, although if you’re using UniFi OS, the cloudkey shouldn’t be reachable at port 8443, this was the change that specifically broke my installation.

I’m also running UniFi 5.14.23 (I downgraded it from 6+) which may be relevant, but if you’re stuck on “uninitialized” and not “connection error” error messages, that sounds more like a OH issue. I’d try deleting the Thing, restarting, purging cache, fiddling with Thing settings, etc.

Im not using a Cloud key, im using the Controller on Windows

Hi guys, I’ve been having the following issue since openHAB 2, and now it seems to have followed through to openHAB 3. Every night at midnight, openHab will show my Unifi controller as offline due to communication error, then 7-8 minutes later will re-establish connection again automatically. Due to this length of time, it is causing my openHab to think that everyone has “left” the home because all the phones also go offline at the same time, causing it to activate “Away” mode. Anyone know of this issue?

My UniFi controller is on a 1st gen Cloud Key, Controller version 6.1.71 about to upgrade to 6.2.26.

Every time I log into my controller UI, I have to go past the “not secure” as I don’t have a signed SSL cert as it’s only for localhost use.

Every night at midnight when OpenHab gives the below error I go and log in to my UniFi controller UI and I can log in just fine.

Logs below:

2021-08-10 00:00:06.115 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'unifi:controller:home' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Unknown HTTP status code 503 returned by the controller
2021-08-10 00:00:06.116 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'unifi:wirelessClient:home:Huawei_P30_Pro' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)
2021-08-10 00:00:06.116 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'unifi:wirelessClient:home:Huawei_P20_Pro' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)

2021-08-10 00:08:41.077 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'unifi:controller:home' changed from OFFLINE (COMMUNICATION_ERROR): Unknown HTTP status code 503 returned by the controller to ONLINE
2021-08-10 00:08:41.079 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'unifi:wirelessClient:home:Huawei_P30_Pro' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2021-08-10 00:08:41.079 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'unifi:wirelessClient:home:Huawei_P20_Pro' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE

Anyone have any ideas on the above please? Happened again tonight at midnight, just like clockwork.

It works! (@dastrix80) I’ve gotten the it to work by manually merging the commit that added the UniFi-OS code and then recompiling the UniFi Jars. Here they are:
2.5.13 UniFi binding fix with UniFi OS support
To use these you’ll need to:

I cannot thank you enough for this! So awesome!
My presence sensing has been completely broken since I upgraded to a UDM Pro but don’t have the time or inclination just now to move my whole Openhab install to 3.x.
Cheers!

I still cant get it working.

my controller runs on port 8443, does the Unifi OS normally use just straight 443?

I get this stupid long error:

20:41:31.002 [WARN ] [org.eclipse.jetty.server.HttpChannel ] - /rest/things/unifi:controller:7ef21b93/config
javax.servlet.ServletException: javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.StackOverflowError
        at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:88) ~[?:?]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.Server.handle(Server.java:494) ~[bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:374) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:268) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:367) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782) [bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:918) [bundleFile:9.4.20.v20190813]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]
Caused by: javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.StackOverflowError
        at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:489) ~[?:?]
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) ~[?:?]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) ~[?:?]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) ~[?:?]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) ~[?:?]
        at com.eclipsesource.jaxrs.publisher.internal.ServletContainerBridge.service(ServletContainerBridge.java:76) ~[?:?]
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) ~[?:?]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544) ~[?:?]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) ~[?:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) ~[?:?]
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536) ~[?:?]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) ~[?:?]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) ~[?:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[?:?]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) ~[?:?]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) ~[?:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[?:?]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) ~[?:?]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) ~[?:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[?:?]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) ~[?:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[?:?]
        at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) ~[?:?]
        ... 15 more
Caused by: org.glassfish.jersey.server.ContainerException: java.lang.StackOverflowError
        at org.glassfish.jersey.servlet.internal.ResponseWriter.rethrow(ResponseWriter.java:278) ~[?:?]
        at org.glassfish.jersey.servlet.internal.ResponseWriter.failure(ResponseWriter.java:260) ~[?:?]
        at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:509) ~[?:?]
        at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:334) ~[?:?]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) ~[?:?]
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) ~[?:?]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315) ~[?:?]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297) ~[?:?]
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267) ~[?:?]
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) ~[?:?]
        at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) ~[?:?]
        at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) ~[?:?]
        at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473) ~[?:?]
        at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) ~[?:?]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) ~[?:?]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) ~[?:?]
        at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) ~[?:?]
        at com.eclipsesource.jaxrs.publisher.internal.ServletContainerBridge.service(ServletContainerBridge.java:76) ~[?:?]
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:852) ~[?:?]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:544) ~[?:?]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) ~[?:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) ~[?:?]
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:536) ~[?:?]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) ~[?:?]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1581) ~[?:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[?:?]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1307) ~[?:?]
        at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) ~[?:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[?:?]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:482) ~[?:?]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549) ~[?:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[?:?]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1204) ~[?:?]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[?:?]
        at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) ~[?:?]
        ... 15 more
Caused by: java.lang.StackOverflowError
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_232]
        at org.osgi.framework.FrameworkUtil.getBundle(FrameworkUtil.java:208) ~[osgi.core-6.0.0.jar:?]
        at org.ops4j.pax.logging.spi.support.BundleHelper.getCallerBundle(BundleHelper.java:77) ~[bundleFile:?]
        at org.ops4j.pax.logging.spi.support.BundleHelper.getCallerBundle(BundleHelper.java:53) ~[bundleFile:?]
        at org.ops4j.pax.logging.OSGIPaxLoggingManager.getLogger(OSGIPaxLoggingManager.java:71) ~[bundleFile:?]
        at org.ops4j.pax.logging.slf4j.Slf4jLoggerFactory.getLogger(Slf4jLoggerFactory.java:51) ~[bundleFile:?]
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358) ~[bundleFile:?]
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383) ~[bundleFile:?]
        at org.openhab.binding.unifi.internal.api.model.UniFiControllerRequest.<init>(UniFiControllerRequest.java:74) ~[?:?]
        at org.openhab.binding.unifi.internal.api.model.UniFiController.newRequest(UniFiController.java:202) ~[?:?]
        at org.openhab.binding.unifi.internal.api.model.UniFiController.login(UniFiController.java:108) ~[?:?]
        at org.openhab.binding.unifi.internal.api.model.UniFiController.executeRequest(UniFiController.java:211) ~[?:?]
        at org.openhab.binding.unifi.internal.api.model.UniFiController.login(UniFiController.java:115) ~[?:?]
        at org.openhab.binding.unifi.internal.api.model.UniFiController.executeRequest(UniFiController.java:211) ~[?:?]
        at org.openhab.binding.unifi.internal.api.model.UniFiController.login(UniFiController.java:115) ~[?:?]
        at org.openhab.binding.unifi.internal.api.model.UniFiController.executeRequest(UniFiController.java:211) ~[?:?]
        at org.openhab.binding.unifi.internal.api.model.UniFiController.login(UniFiController.java:115) ~[?:?]
        at org.openhab.binding.unifi.internal.api.model.UniFiController.executeRequest(UniFiController.java:211) ~[?:?]

Mathew, I am using 6.2.26. and fount that UniFi controller going offline when makes backup.
I went to Settings → System Settings → Maintenance → Backup/Restore and changed Backup Scheduler for my needs.