Ubiquiti Unifi Binding Feature Discussion

it works perfectly for me :slight_smile:

question: how can I transform the “uptime” in a more readable format?

thanks
Andrea

Here is my rule to do just that.

rule "Format Joe's Phone Uptime"
when
    Item JoesPhoneUptime changed
then	
	var int days = ((JoesPhoneUptime.state as DecimalType).intValue / (86400))
	var int hours = (((JoesPhoneUptime.state as DecimalType).intValue / 3600) - (24 * days))
	var int minutes = (((JoesPhoneUptime.state as DecimalType).intValue / 60) - ((1440 * days) + (60 * hours)))
	var int seconds = (((JoesPhoneUptime.state as DecimalType).intValue) - ((86400 * days) + (3600 * hours) + (60 * minutes)))
	var String result = ""
// days
	if (days > 0) {
		result = result + days + " Day / "
	}
// hours
	if (hours > 0) {
		result = result + hours + " Hours / "
	}
// minutes
	if (minutes > 0) {
		result = result + minutes + " Min / "
	}
// seconds
	if (seconds > 0) {
		result = result + seconds + " Sec "
	}		
	JoesPhoneUptimeFormatted.postUpdate(result)
	logInfo("system.rules", "Uptime updated to " + JoesPhoneUptimeFormatted.state)
end
2 Likes

that’s excellent, thanx!
(edit): It works fine ! (I forgot the [%s] at the String Item description :stuck_out_tongue:)

Glad it works, of course I just modified someone else’s to make it work, it all about sharing to make our home smarter.

1 Like

I updated to 2.3.0 a coupple of days ago. And I have had a hell with my Openhab2 system ever since…

I´m not sure if I did something wrong, but I DL the 2.3.0 snapshot, placed it in my /usr/share/openhab2/addons folder. Renamed the old 2.2.0 to .old
And the problems felt all over me.

  1. OpenHab2 would no load 2.3.0. and kept telling me, it could parse 2.2.0 file, (ofcuse cause I renamed it).
  2. Read somewere to clear the cache and tmp folders. So I did. Made some changes, as I now run the 2.3.0 Unif binding.
  3. If I try to install something (another binding, service etc) the “old” problem returns where Openhab says it can´t run the 2.2.0 binding.
  4. For a few minutes ago, I try to update some files from the openhabian-config console. After that I rebooted the system… And now I get this when i reboots:
2018-05-06 23:16:02.809 [WARN ] [ig.xml.osgi.XmlDocumentBundleTracker] - The XML document '/ESH-INF/binding/binding.xml' in module 'org.openhab.binding.unifi' could not be parsed: The XmlConfigDescriptionProvider must not be null!
java.lang.IllegalArgumentException: The XmlConfigDescriptionProvider must not be null!
	at org.eclipse.smarthome.core.binding.xml.internal.BindingInfoXmlProvider.<init>(BindingInfoXmlProvider.java:60) [117:org.eclipse.smarthome.core.binding.xml:0.10.0.b1]
	at org.eclipse.smarthome.core.binding.xml.internal.XmlBindingInfoProvider.createDocumentProvider(XmlBindingInfoProvider.java:141) [117:org.eclipse.smarthome.core.binding.xml:0.10.0.b1]
	at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.acquireXmlDocumentProvider(XmlDocumentBundleTracker.java:181) [113:org.eclipse.smarthome.config.xml:0.10.0.b1]
	at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.addingObject(XmlDocumentBundleTracker.java:206) [113:org.eclipse.smarthome.config.xml:0.10.0.b1]
	at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.parseDocuments(XmlDocumentBundleTracker.java:350) [113:org.eclipse.smarthome.config.xml:0.10.0.b1]
	at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.processBundle(XmlDocumentBundleTracker.java:336) [113:org.eclipse.smarthome.config.xml:0.10.0.b1]
	at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker.access$3(XmlDocumentBundleTracker.java:331) [113:org.eclipse.smarthome.config.xml:0.10.0.b1]
	at org.eclipse.smarthome.config.xml.osgi.XmlDocumentBundleTracker$2.run(XmlDocumentBundleTracker.java:307) [113:org.eclipse.smarthome.config.xml:0.10.0.b1]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]

And this one:

2018-05-06 23:16:39.391 [ERROR] [org.openhab.binding.unifi           ] - FrameworkEvent ERROR - org.openhab.binding.unifi
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.unifi [239]
  Another singleton bundle selected: osgi.identity; type="osgi.bundle"; version:Version="2.3.0.201804221805"; osgi.identity="org.openhab.binding.unifi"; singleton:="true"
	at org.eclipse.osgi.container.Module.start(Module.java:444) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1620) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1600) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1571) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1514) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]

Funny thing is… It does work and run using the 2.3.0 shapshot.

Now… what to do??

check the openHAB console to see if the old version is still being listed:

openhab> bundle:list -s |grep unifi
190 │ Active   │  80 │ 2.3.0.201804221805     │ org.openhab.binding.unifi

Only 1 line should appear

Make sure that you have removed the old jar from:

root@homer:~# l /usr/share/openhab2/addons/org.openhab.binding.unifi-2.3.0-SNAPSHOT.jar 
-rw-r--r-- 1 openhab openhab 39055 21:06 22-Apr-2018 /usr/share/openhab2/addons/org.openhab.binding.unifi-2.3.0-SNAPSHOT.jar

Stop OH2, clear cache & tmp folders

Start OH2

It should work :slight_smile:

Ps: Using build #10 from https://jenkins.otr.mx/job/openhab2-unifi-binding-v2/

Both are listet: :face_with_raised_eyebrow:

openhab> bundle:list -s |grep unifi
 27 │ Active    │  80 │ 2.3.0.201804221805     │ org.openhab.binding.unifi
239 │ Installed │  80 │ 2.2.0.201709191042     │ org.openhab.binding.unifi
openhab>

How to remove the old one?

And second - Why the heck does this happen?

make sure that you don’t have 2 jars in addons and clear tmp + cache
if it still appears: try bundle:uninstall 239 (or something similar… i can’t check atm)

I renamed version 2.2.0.jar in the addons folder, (renamed it´s extention to .old), and afterwards cleared the cache/tmp folders. This is where my problems started in the first place. Is renaming not enough?

I can however give it another go, and delete the version 2.2.0 first. I just wonder why rename it´s extension shouldn´t work.

Gave it a new try. (actually 2 tries as the first try gave me problems again with 2.3.0 failing to load).
Second try I downloaded a fresh copy of the jar file (build 10). Cleared the cache/tmp again, and started Openhab service…

Now I don´t get any errors. 2.3.0 loads fine, and no errors about 2.2.0 not beeing found. (Guess it´s gone for good now).

So I guess everything is fine now… Thx for you´r help.

1 Like

Does this binding oly show devices attached to APs, or also other fix LAN devices if they have a valid mac address?

I tried it with two lan devices that the controller can see and it didn’t seem to trigger an online status

I tried as well. Same result as yours.
I guess it would only work for wireless devices. I do not see why though.

No neither. Though I remember playing with the Unifi API and it allowed you to cycle through all the connected devices on an AP…but there is an overall client list, as I use it for feeding an influxdb with data usage per device.

Hi,
this thread has grown to 368 posts. For someone just joining in this is a lot to read. Is there a documentation of how to set up and use the binding? Maybe even for manual setup?
Thanks in advance!
Alex

Here’s a link to the documentation that is part of the latest revision of the binding.

1 Like

Thanks! That’s what I was looking for.
Now I somehow need to get the lastSeen on the sitemap to show in the local timezone… :slight_smile:

EDIT: Solved timezone issue. I needed to add the timezone to the EXTRA_JAVA_OPTS. Setting it under “System” in PaperUI was not enough. I know this is not a UniFi Binding issue, but a OpenHAB2 one…

EDIT2: @mgbowman Maybe the link to the documentation can be added to the first post?

Great job on this!

It took me 1/2 hour and I was up and running with it using Synology NAS with OH2.3.

My only suggestion would be to report the THINGS as being offline when controller HTTP port is down. In the log file it’s just giving a HTTP error of 503 and the THINGS are still online.

Best, Jay

Guys,

receiving this log:

2018-06-21 12:00:31.760 [WARN ] [.handler.UniFiControllerThingHandler] - Unhandled exception while refreshing the UniFi Controller unifi:controller:7846a3b1 - java.net.SocketTimeoutException: Connect Timeout
2018-06-21 12:03:56.160 [WARN ] [.handler.UniFiControllerThingHandler] - Unhandled exception while refreshing the UniFi Controller unifi:controller:7846a3b1 - Unknown HTTP status code 503 returned by the controller
2018-06-21 13:36:56.608 [WARN ] [.handler.UniFiControllerThingHandler] - Unhandled exception while refreshing the UniFi Controller unifi:controller:7846a3b1 - Not a JSON Object: null
2018-06-21 15:56:00.532 [WARN ] [.handler.UniFiControllerThingHandler] - Unhandled exception while refreshing the UniFi Controller unifi:controller:7846a3b1 - Not a JSON Object: null
2018-06-21 16:22:14.251 [WARN ] [.handler.UniFiControllerThingHandler] - Unhandled exception while refreshing the UniFi Controller unifi:controller:7846a3b1 - Not a JSON Object: null

version 2.3.0.201804221805

Any clue?

thanks
Andrea

Hello again,

now that I have the presence part working, I’m already starting with a feature request :slight_smile:
It would be great if one could not only read info about clients, but also do changes in the controller. I would like to enable and disable the guest network.

Cheers
Alex

See post above yours: the binding cannot reach the controller.

  • Is the IP and port set up correctly?
  • Can you reach that IP:port from the system where Openhab is installed (use telnet, netcat, or socat from the command line)
1 Like