Ubiquiti Unifi Binding Feature Discussion

@hakan update and try again. I added some additional logging and changed the unknown states from UnDefType.NULL to UnDefType.UNDEF


Binding URL: org.openhab.binding.unifi-2.1.0-SNAPSHOT.jar
Latest Version: 2.1.0.201704091001

I was hoping someone would make a binding like this :slight_smile:

I’m trying to get it to work with a 5.4.11 controller.
I added things manually, and configured the debug logging as above. But I don’t seem to get any data.
The log file stays empty and the items I linked to the channels of the things don’t seem to get values.

I have updated the binding, but it is still not fully functioning yet… When I activate the “ap” channel though the Paper UI, I am still getting the NPEs, and cannot see the logging statements that should come if I read your code change correctly…

openhab> bundle:list | grep -i unifi
240 | Active   |  80 | 2.1.0.201704091001    | UniFi Binding

Maybe my bundle update procedure is wrong. Try stopping and uninstalling the existing bundle and restart OH. Then do a bundle:install [url] followed by a bundle:start "UniFi Binding" and see if that helps.

What version of the controller are you running?

Actually, I believe your update procedure is fine. I can see a difference betwenn the version yesterday and the one from today. The previous one would kill the complete “Control” tab in the Paper UI, with the one from today, I just get a broken line for the “ap” item. And, of course, the NPE stays :slight_smile:

5.4.11, running in a docker image from https://github.com/goofball222/unifi

The docker part should have no impact on you, though, as you just fetch the json stream, right?

Also, I have a specific user configured in unifi which has only read-only permissions.

I’m running the same version in Docker using the linuxserver/unifi image

2 for 2 - I do the same thing and that’s the user I’ve been developing / testing with.

I added more TRACE logging to dump the raw JSON content coming back from the controller. Please update to the latest and configure your userdata/etc/org.ops4j.pax.logging.cfg like so:

# UniFi logger
log4j.logger.org.openhab.binding.unifi = TRACE, unifi
log4j.additivity.org.openhab.binding.unifi = false

# File appender - unifi.log
log4j.appender.unifi=org.apache.log4j.RollingFileAppender
log4j.appender.unifi.layout=org.apache.log4j.PatternLayout
log4j.appender.unifi.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-26.26c{1}] - %m%n
log4j.appender.unifi.file=${openhab.logdir}/unifi.log
log4j.appender.unifi.append=true
log4j.appender.unifi.maxFileSize=10MB
log4j.appender.unifi.maxBackupIndex=10

@hakan if you don’t mind, please send me your unifi.log file via PM - it’s really bugging me why this is not working for you.


Binding URL: org.openhab.binding.unifi-2.1.0-SNAPSHOT.jar
Latest Version: 2.1.0.201704091438

Should this work with the Cloud Key or does it only work with the controller software?

@roryd I don’t see why it wouldn’t as the cloud key is just an embedded platform running what I believe is the same controller software. Are you having issues getting the latest binding working?

Hi Matthew,

I haven’t been able to get the things to show as online. I’ve set up the things, items and sitemap files and also set up the unifi.log but although the items appear in the log file, none of them seem to be seen as attached to the network. I’m using the 1438 binding version from today, but I still can’t get it to work.

@roryd Did you enable TRACE level logging as shown here? If so, do you see JSON output in the unifi.log file? If you don’t mind sharing, I’d be happy to look through your log. You can send it via PM and please include your unifi.things and unifi.items definitions.

Without seeing the log file I’m afraid there’s not much more I can do to help you.

@mgbowman yes, I can see the JSON data alright. I’ll PM you the others.

@hakan Update and try again - I think we’ve solved your issue.


Binding URL: org.openhab.binding.unifi-2.1.0-SNAPSHOT.jar
Latest Version: 2.1.0.201704101035

Works much better now :smile:

I have one device without a host name in my network (“netatmo”) which shows the MAC of my AP as “Access Point” information, and the NullPointerException from the mqtt log is fixed too.

My other device (my phone) is not in the network right now, and all data for it is shown as “-” in the Paper UI. I will see what happens when I get home tonight.

1 Like

After updating to todays version I’m getting JSON data aswel, and I get 20 clients found (I also have a unifi switch).
But the mac addresses I configured as things are not found, even though I can see them in the /sta JSON output.

I tried to specify the site, or leave it empty, but the result stays the same.

A cool addition would be to add the found clients to the inbox on the paperui?

This would be the “Discovery” functionality :wink:

I could always try and discover https://ubnt:ubnt@unifi:8443 since that’s the default :smile:
I highly doubt anyone using OH would ever leave it open like that … but you never know.

No, don’t try to discover the controller, we should configure that using the configure button on the binding ;), but after that discover the wired and wireless clients.

Yeah @roryd is having the same problem and I’m trying to help him figure it out.

With DEBUG logging on, do you get any output on the lines after Found x UniFi Client(s) like so:

2017-04-10 20:30:27.101 [DEBUG] [unifi.internal.UniFiController:231  ] - Found 10 UniFi Client(s):
2017-04-10 20:30:27.102 [DEBUG] [unifi.internal.UniFiController:234  ] -   hostname = ..., mac = ..., essid = ..., rssi = ..., ap = ...
2017-04-10 20:30:27.102 [DEBUG] [unifi.internal.UniFiController:234  ] -   hostname = ..., mac = ..., essid = ..., rssi = ..., ap = ...
2017-04-10 20:30:27.102 [DEBUG] [unifi.internal.UniFiController:234  ] -   hostname = ..., mac = ..., essid = ..., rssi = ..., ap = ...
<...snip...>

Binding URL: org.openhab.binding.unifi-2.1.0-SNAPSHOT.jar
Latest Version: 2.1.0.201704101542

This could work.

For now, let’s figure out why you and @roryd aren’t seeing any updates while @hakan and I are :confused:

@roryd and @l_grave please update and try again.

I believe it comes down to you two having wired clients and all my work has been under the assumption of wireless clients. I’m getting a USW-8 at the office soon so I’ll be able to better support both wired and wireless clients in the future.


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