Ubiquiti Unifi Binding Feature Discussion

Hello @mgbowman I was wondering wether you were already planning on creating a pull request so we can include the binding in the master in between already in the marketplace

What is your idea about this?

5 Likes

Hi @martinvw

Iā€™ve always planned to get my binding into master but wanted the development / testing to settle down before I created a PR.

My last build was 28 days ago and so far everybody in this thread who helped test has reported everything is in working order. I think itā€™s stable enough to pull.

However, Iā€™m leaving for vacation and my hands are full these next few days. Once I return, Iā€™ll do a rebase and squash to create a nice clean PR and hopefully get this into the next release.

Cheers!

7 Likes

Great, thanks for the update! And have a nice holiday!

Very nice work with the binding, working fine for me with the latest version of everything (openhab2, binding, unifi).

Have any of you worked out a simple rule to debounce presence detection when certain devices just disconnect from wifi every few minutes due to power saving?

Hi! I just update to version from 1st of Mayā€¦ The mac addresses seems to be case sensitive.

.... (my mobile phone)
2017-06-07 18:47:19.981 [DEBUG] [nding.unifi.internal.UniFiController] -   UniFiClient{mac: '**ec:9b:f3:5e:78:1a**', hostname: 'android-66f7051423a9c68d', wired: false, device: UniFiDevice{mac: '80:2a:a8:83:1a:94', name: 'Dachboden', model: 'U7PG2', site: Site{name: 'mySite', path: 'default'}}}

.... more clients

2017-06-07 18:47:20.024 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = 8c:f5:a3:af:4b:80, site = null
2017-06-07 18:47:20.030 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Refreshing channel = unifi:client:513ad07b:site
... some other refreshings
2017-06-07 18:47:20.054 [DEBUG] [ing.unifi.handler.UniFiClientHandler] - Could not find a matching client: mac = **EC:9B:F3:5E:78:1A**, site = null

Volker

Hi @volkerrichert

This is odd as I do a StringUtils.lowerCase(StringUtils.trim(...)) on both the client config and the json deserialization so the comparison shoud be case-insensitive.

Iā€™ll double check tonight that both of these are actually getting called and report back.

I converted the MACs to lowercase and itā€™s working now. I can support you by staring a debug session, if you like.

Volker

So it turns out the built-in getConfig().as(...) calls access the fields directly via reflection instead of calling the setters. As a result, the setter in my client config class was never getting called.

Iā€™ve pushed an update to the binding to make use of a tidy() function to clean the config values and hence make MAC address comparisons case-insensitive.

If you donā€™t mind, please update your binding and try again with your original MAC addresses and report back if this fixed your issue.

Thanks!


UniFi Binding v2.1.0.201706081307 : org.openhab.binding.unifi-2.1.0-SNAPSHOT.jar

3 Likes

@mgbowman One thing I noticed, and this is pretty minorā€¦ I had my cable modem disconnected for a few minutes in order to reroute some cables. Noticed these log messages.

Note that this is the configuration where the Unifi Controller is on the other end of an IPSEC tunnel from the openHAB instance.

Wondering why it switched from the WARN to the ERROR level log message. Possibly the connection attempt failed on the WARN, and the DNS lookup failed (UnknownHostException) on the ERROR. Not sure if it was your intention to log a stack trace on this type of problem.

Again, pretty minor in the whole scheme of things.

2017-06-09 07:32:36.879 [WARN ] [unifi.handler.UniFiControllerHandler] - Error refreshing the UniFi Controller unifi:controller:7036b81d - Could not communicate with the UniFi Controller
2017-06-09 07:32:46.867 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:32:56.869 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:33:06.866 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:33:16.865 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:33:26.864 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:33:36.926 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:33:46.865 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:33:56.866 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:34:06.865 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:34:16.869 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:34:26.862 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:34:36.866 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:34:46.865 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:34:56.869 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:35:06.864 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:35:16.865 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:35:26.866 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:35:36.868 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:35:46.865 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:35:56.861 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:36:06.864 [WARN ] [nding.unifi.internal.UniFiController] - Could not connect to the UniFi Controller
2017-06-09 07:36:31.881 [ERROR] [nding.unifi.internal.UniFiController] - Error trying to authenticate to UniFi Controller
java.net.UnknownHostException: unifi
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)[:1.8.0_131]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)[:1.8.0_131]
	at java.net.Socket.connect(Socket.java:589)[:1.8.0_131]
	at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)[:1.8.0_131]
	at sun.net.NetworkClient.doConnect(NetworkClient.java:175)[:1.8.0_131]
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)[:1.8.0_131]
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)[:1.8.0_131]
	at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)[:1.8.0_131]
	at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)[:1.8.0_131]
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)[:1.8.0_131]
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1138)[:1.8.0_131]
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032)[:1.8.0_131]
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)[:1.8.0_131]
	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1316)[:1.8.0_131]
	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1291)[:1.8.0_131]
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)[:1.8.0_131]
	at org.openhab.binding.unifi.internal.UniFiController.get(UniFiController.java:132)[10:org.openhab.binding.unifi:2.1.0.201705010628]
	at org.openhab.binding.unifi.internal.UniFiController.get(UniFiController.java:155)[10:org.openhab.binding.unifi:2.1.0.201705010628]
	at org.openhab.binding.unifi.internal.UniFiController.login(UniFiController.java:192)[10:org.openhab.binding.unifi:2.1.0.201705010628]
	at org.openhab.binding.unifi.handler.UniFiControllerHandler.refresh(UniFiControllerHandler.java:130)[10:org.openhab.binding.unifi:2.1.0.201705010628]
	at org.openhab.binding.unifi.handler.UniFiControllerHandler.run(UniFiControllerHandler.java:177)[10:org.openhab.binding.unifi:2.1.0.201705010628]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_131]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_131]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_131]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_131]
	at java.lang.Thread.run(Thread.java:748)[:1.8.0_131]
2017-06-09 07:36:31.884 [ERROR] [nding.unifi.internal.UniFiController] - Error trying to authenticate to UniFi Controller
java.net.UnknownHostException: unifi
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)[:1.8.0_131]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)[:1.8.0_131]
	at java.net.Socket.connect(Socket.java:589)[:1.8.0_131]
	at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)[:1.8.0_131]
	at sun.net.NetworkClient.doConnect(NetworkClient.java:175)[:1.8.0_131]
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)[:1.8.0_131]
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)[:1.8.0_131]
	at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)[:1.8.0_131]
	at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)[:1.8.0_131]
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)[:1.8.0_131]
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1138)[:1.8.0_131]
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032)[:1.8.0_131]
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)[:1.8.0_131]
	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1316)[:1.8.0_131]
	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1291)[:1.8.0_131]
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)[:1.8.0_131]
	at org.openhab.binding.unifi.internal.UniFiController.get(UniFiController.java:132)[10:org.openhab.binding.unifi:2.1.0.201705010628]
	at org.openhab.binding.unifi.internal.UniFiController.get(UniFiController.java:155)[10:org.openhab.binding.unifi:2.1.0.201705010628]
	at org.openhab.binding.unifi.internal.UniFiController.login(UniFiController.java:192)[10:org.openhab.binding.unifi:2.1.0.201705010628]
	at org.openhab.binding.unifi.handler.UniFiControllerHandler.refresh(UniFiControllerHandler.java:130)[10:org.openhab.binding.unifi:2.1.0.201705010628]
	at org.openhab.binding.unifi.handler.UniFiControllerHandler.run(UniFiControllerHandler.java:177)[10:org.openhab.binding.unifi:2.1.0.201705010628]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_131]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_131]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_131]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_131]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_131]
	at java.lang.Thread.run(Thread.java:748)[:1.8.0_131]

Wow this is great. I had to install the JSONPath transformation to get it to work, but after that I was off and running.

Is there a way to get some additional stats from the controller?
Examples:
How many devices are associated to an AP
AP uptime and general stats
Information on the internet connection from USG

Thank you for this binding, it works great now that I got it working.

In case someone else has installation issues like I did, I too had an issue with an error related to missing dependencies:

2017-06-08 21:53:31.127 [ERROR] [org.openhab.binding.unifi           ] - FrameworkEvent ERROR - org.openhab.binding.unifi
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.unifi [198]
  Unresolved requirement: Import-Package: com.fasterxml.jackson.annotation

Installation of the JSONPath Transformation binding did not resolve this error for me. However, installing the following jar files from the Maven website in the addons folder did resolve the issue:

jackson-annotations-2.8.8.jar
jackson-core-2.8.8.jar
jackson-databind-2.8.8.1.jar

After a reinstall of OpenHAB 2.1.0-snapshot Iā€™m having the same issue. I guess there is something wrong with the dependency resolving/packaging.

I think that something else is wrongā€¦

I already have the jackson stuff activated in my OH2 but I also get the same error sometimes (especially during the first startup following an apt-get upgradeā€¦maybe because the tmp and cache folders are being cleaned up and the binding starts too fast before the dependencies become active ?)

openhab> list -s |grep jackson
181 | Active   |  80 | 2.4.5                  | Jackson-annotations                                    | com.fasterxml.jackson.core.jackson-annotations
182 | Active   |  80 | 2.4.5                  | Jackson-core                                           | com.fasterxml.jackson.core.jackson-core
183 | Active   |  80 | 2.4.5                  | jackson-databind                                       | com.fasterxml.jackson.core.jackson-databind
184 | Active   |  80 | 2.4.5                  | Jackson-dataformat-YAML                                | com.fasterxml.jackson.dataformat.jackson-dataformat-yaml

If I restart OH2 following the upgrade, I donā€™t have this error (I havenā€™t seen it appearing in my system at least)

Ps: In the error it is mentioned: com.fasterxml.jackson.annotation ā€¦ should this be com.fasterxml.jackson.annotations (with s at the end) or itā€™s fine?

I canā€™t pinpoint it but here are 2 logs that might be of some help:

When I stop and then start OH2, no error appears.

When I upgrade OH2 to the latest snapshot (#945 this time), I (almost?) always get the same jackson error.

Log 1: Clean start:

2017-06-11 00:39:32.568 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at http://172.16.13.100:8081
2017-06-11 00:39:32.569 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at https://172.16.13.100:8444
2017-06-11 00:39:32.570 [DEBUG] [org.openhab.binding.unifi           ] - BundleEvent STARTING - org.openhab.binding.unifi
2017-06-11 00:39:32.610 [DEBUG] [org.openhab.binding.unifi           ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.Thing
HandlerFactory}={component.name=binding.unifi, component.id=144, service.id=271, service.bundleid=177, service.scope=bundle} - org.openhab.binding
.unifi
2017-06-11 00:39:32.658 [DEBUG] [org.openhab.binding.unifi           ] - BundleEvent STARTED - org.openhab.binding.unifi
2017-06-11 00:39:33.085 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'mpower:mpower:04_18_D6_59_FD_EA' to inbox.
2017-06-11 00:39:33.116 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'mpower:mpower:24_A4_3C_87_61_D3' to inbox.
2017-06-11 00:39:33.128 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'mpower:mpower:24_A4_3C_87_61_EA' to inbox.
2017-06-11 00:39:33.204 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2017-06-11 00:39:33.244 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2017-06-11 00:39:33.878 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'ntp:ntp:local' to inbox.
2017-06-11 00:39:34.661 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin servlet at /habmin
2017-06-11 00:39:34.696 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2017-06-11 00:39:42.946 [INFO ] [unifi.handler.UniFiControllerHandler] - UniFi Binding v2.1.0.201706081307
2017-06-11 00:39:42.948 [DEBUG] [unifi.handler.UniFiControllerHandler] - Initializing the UniFi Controller Handler with config = UniFiControllerCo
nfig{host = 172.16.13.100, port = 8443, username = angelos, password = *****, refresh = 10}
2017-06-11 00:39:43.091 [DEBUG] [unifi.handler.UniFiControllerHandler] - Scheduling refresh job every 10s
2017-06-11 00:39:43.091 [TRACE] [unifi.handler.UniFiControllerHandler] - Executing refresh job
2017-06-11 00:39:43.091 [DEBUG] [unifi.handler.UniFiControllerHandler] - Trying to establish communication with the UniFi controller
2017-06-11 00:39:43.108 [TRACE] [nding.unifi.internal.UniFiController] - Sending the following headers to https://172.16.13.100:8443/api/login
2017-06-11 00:39:43.859 [TRACE] [nding.unifi.internal.UniFiController] - Received the following headers from https://172.16.13.100:8443/api/login
2017-06-11 00:39:43.860 [TRACE] [nding.unifi.internal.UniFiController] - X-Frame-Options : [DENY]
2017-06-11 00:39:43.860 [TRACE] [nding.unifi.internal.UniFiController] - null : [HTTP/1.1 200 OK]
2017-06-11 00:39:43.860 [TRACE] [nding.unifi.internal.UniFiController] - Server : [Apache-Coyote/1.1]
2017-06-11 00:39:43.860 [TRACE] [nding.unifi.internal.UniFiController] - Set-Cookie : [csrf_token=hpLa4qqicv2KAzHSBU4DGKXwDh9fTUsb; Path=/; Secure
, unifises=7jkp1X4kqApM4sAXZTEleke8gukvNfcy; Path=/; Secure; HttpOnly]
2017-06-11 00:39:43.861 [TRACE] [nding.unifi.internal.UniFiController] - Content-Length : [41]
2017-06-11 00:39:43.861 [TRACE] [nding.unifi.internal.UniFiController] - Date : [Sat, 10 Jun 2017 21:39:43 GMT]
2017-06-11 00:39:43.861 [TRACE] [nding.unifi.internal.UniFiController] - Content-Type : [application/json;charset=UTF-8]

Log 2: Error Log:

2017-06-11 00:41:22.553 [INFO ] [org.apache.felix.fileinstall        ] - Updating configuration from profile.cfg
2017-06-11 00:41:24.828 [INFO ] [org.apache.felix.fileinstall        ] - Installing bundle org.openhab.binding.mpower;singleton:=true / 2.0.2.2017
01242116
2017-06-11 00:41:24.832 [INFO ] [org.apache.felix.fileinstall        ] - Installing bundle org.openhab.binding.unifi;singleton:=true / 2.1.0.20170
6081307
2017-06-11 00:41:24.834 [DEBUG] [org.openhab.binding.unifi           ] - BundleEvent INSTALLED - org.openhab.binding.unifi
2017-06-11 00:41:25.864 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.
binding.unifi-2.1.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.unifi [10]
  Unresolved requirement: Import-Package: com.fasterxml.jackson.annotation

	at org.eclipse.osgi.container.Module.start(Module.java:434)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:392)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1253)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1225)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312)[4:org.apache.felix.fileinstall:3.5.6]
2017-06-11 00:41:25.867 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.
binding.mpower-2.0.02-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.mpower [9]
  Unresolved requirement: Import-Package: com.google.common.base; version="10.0.1"

	at org.eclipse.osgi.container.Module.start(Module.java:434)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:392)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1253)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1225)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312)[4:org.apache.felix.fileinstall:3.5.6]
2017-06-11 00:41:26.503 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.
binding.unifi-2.1.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.unifi [10]
  Unresolved requirement: Import-Package: com.fasterxml.jackson.annotation

	at org.eclipse.osgi.container.Module.start(Module.java:434)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:392)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1253)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1225)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312)[4:org.apache.felix.fileinstall:3.5.6]
2017-06-11 00:41:26.505 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.
binding.mpower-2.0.02-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.mpower [9]
  Unresolved requirement: Import-Package: com.google.common.base; version="10.0.1"

	at org.eclipse.osgi.container.Module.start(Module.java:434)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:392)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1253)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1225)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312)[4:org.apache.felix.fileinstall:3.5.6]
2017-06-11 00:41:40.206 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at http://172.16.13.100:8081
2017-06-11 00:41:40.206 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at https://172.16.13.100:8444

It seems to me that the felix installer tries to start the binding too fast (even before the dashboards) and it fails to activate it because the dependencies are not loaded (activated?) yet. This sounds more like a general OH2 issue and not so much a binding issue but I may be wrong.
Same story with the Ubiquiti mPower binding by the way.

After the first start following the upgradeā€¦ a simple restart puts the system back in normal operations (no errors)

I donā€™t think so, I get the error when OpenHAB runs, and I want to start the bundle in the Karaf console. So everything is loaded at that moment.

side note (not related to the Unifi binding):
If you are running Debian (Jessie) or Ubuntu, do not apt-get upgrade your system today (20/Jun/2017) cause it will break Unifi Controller, Unifi Video NVR and mFi Controllerā€¦ most possibly the new kernel (3.16.43-2+deb8u1) is the root-causeā€¦

If you do upgrade, here is a temp fix (downgrade) for it:

Just wanted to add another thanks for the work on this binding. Of all the presence detection systems I have tried this was by far the easiest to get going, and so far (I just installed it earlier today) seems to be far more reliable than others also. No battery impact on the phone is just icing on the cake.

My only ā€œcomplaintā€ is that it seems to take about 10 minutes for the device to register as offline. This isnā€™t a problem with the binding. I was watching my Unifi controller and thatā€™s how long it took for my phone to fall off of the client list.

The folks over at HA seem to have run into the same issue. A proposed solution there is to use the ā€œlast_seenā€ time for each device. I donā€™t know the mechanics of the binding so I donā€™t know if this would be simple to do. Something to consider at any rate.

@PointandClick glad to hear everything is working for you!

Unfortunately this is how the UniFi controller works :frowning: On the bright side, there are a handful of interesting time related variables in the controllerā€™s JSON API (per-client):

  • _last_seen_by_uap
  • _uptime_by_uap
  • assoc_time
  • first_seen
  • last_seen
  • latest_assoc_time
  • uptime

Using these, I could add some ā€œenhancedā€ logic to the binding similar to HAā€™s approach. Something like a client is still considered online iff it was ā€œseenā€ within the last X minutes. Will have to do some trial and error while debugging the JSON API to see exactly which variables are of interest.

Are there more people interested in having something like this?

1 Like

Yeah, that sounds useful to me. I primarily use the unifi binding to add logic to my presence detection so if it was more definitive in when it determines a device has not been seen it would be helpful.

I think that this would be useful. We could use it in a rule to update the presence as we see fit.

by the way:
I still get that jackson crap warning:

2017-06-24 21:46:57.035 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.unifi-2.1.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.unifi [176]
  Unresolved requirement: Import-Package: com.fasterxml.jackson.annotation

	at org.eclipse.osgi.container.Module.start(Module.java:434)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:392)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1253)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1225)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)[4:org.apache.felix.fileinstall:3.5.6]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312)[4:org.apache.felix.fileinstall:3.5.6]

This happens (to me) whenever I clear tmp & cache (usually after apt-get upgrade)
If I restart OH2 with tmp & cache populatedā€¦ I donā€™t get this error (at least, I havenā€™t seen it till now appearing)
Running OH2 S#965 atm