Just an FYI, the site configuration parameter on the Bridge item was moved to the Thing item to be more flexible. You can read more about this in the UniFi Binding Readme - Bridge Configuration
I’m seeing this exception on the port number every refresh interval.
2017-04-30 17:33:49.580 [ERROR] [nding.unifi.internal.UniFiController] - Error trying to authenticate to UniFi Controller
java.net.MalformedURLException: For input string: "8443.0"
at java.net.URL.<init>(URL.java:627)[:1.8.0_121]
at java.net.URL.<init>(URL.java:490)[:1.8.0_121]
at java.net.URL.<init>(URL.java:439)[:1.8.0_121]
at org.openhab.binding.unifi.internal.UniFiController.openConnection(UniFiController.java:103)[10:org.openhab.binding.unifi:2.1.0.201704270844]
at org.openhab.binding.unifi.internal.UniFiController.get(UniFiController.java:129)[10:org.openhab.binding.unifi:2.1.0.201704270844]
at org.openhab.binding.unifi.internal.UniFiController.get(UniFiController.java:155)[10:org.openhab.binding.unifi:2.1.0.201704270844]
at org.openhab.binding.unifi.internal.UniFiController.login(UniFiController.java:192)[10:org.openhab.binding.unifi:2.1.0.201704270844]
at org.openhab.binding.unifi.handler.UniFiControllerHandler.refresh(UniFiControllerHandler.java:130)[10:org.openhab.binding.unifi:2.1.0.201704270844]
at org.openhab.binding.unifi.handler.UniFiControllerHandler.run(UniFiControllerHandler.java:177)[10:org.openhab.binding.unifi:2.1.0.201704270844]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_121]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_121]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_121]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
Caused by: java.lang.NumberFormatException: For input string: "8443.0"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)[:1.8.0_121]
at java.lang.Integer.parseInt(Integer.java:580)[:1.8.0_121]
at java.lang.Integer.parseInt(Integer.java:615)[:1.8.0_121]
at java.net.URLStreamHandler.parseURL(URLStreamHandler.java:222)[:1.8.0_121]
at java.net.URL.<init>(URL.java:622)[:1.8.0_121]
... 15 more
I’m not sure why this started all of a sudden. I don’t recall seeing any PRs dealing with how ESH deals with integer config items. But, obviously something is different with this latest build.
Looking in the Thing json DB, it looks like the config item is being stored with one decimal place (i.e. 8443.0)
Nope…
I upgraded yesterday to build #904 and my unifi binding logs are clean.
On the other hand… I use a unifi.thing flat file.
I didn’t add the things via PaperUI discovery, so I don’t have any unifi entries in my jsonDB to properly compare.
I will try this on my test-bed OH2 system and let you know.
@mhilbush I pushed an update that adds an intValue() conversion to the port number. Now if for some odd reason the port gets stored as a string, everything should work fine.
FWIW, I reinstalled the build (#904), as well as deleted and readded the controller and client things, and the problem no longer occurs. No idea why that was occurring, but it’s better now.
Happy to report that I just updated my Unifi Controller from v5.4.14 to v5.4.15 and the Unifi Binding from v2.1.0.201704270844 to v2.1.0.201705010628 and all work fine !
Wanted to report that after a couple weeks of runtime, I’ve not had a single issue with the controller bridge going offline due to a comm issue. And that includes the OH instance that’s on the other end of an IPSEC tunnel from the Unifi controller. That OH instance had been having an issue every few days due to sporadic loss of the tunnel.
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
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.
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?
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.
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.
@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]