Ubiquiti Unifi Binding Feature Discussion

I’m not using this binding, I would still suggest you add the bridge using the gui to avoid configuration syntax faults. What firmware version are you using?

I take it you are using the jar provided.by @pagm . Don’t forget to uninstall the original binding. Verify with karaf console you are running the correct one.

Any chance to get that update as an 2.5.x binding update?

1 Like

I updated to OH 3.1.0.M3 today.
And now the 3.1.0-20210208.jar is not working any more.

2021-04-02 10:41:32.254 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/openhab/addons/org.openhab.binding.unifi-3.1.0-20210208.jar

org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.unifi [208]

  Unresolved requirement: Import-Package: org.apache.commons.lang; version="[2.6.0,3.0.0)"

	at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi-3.12.100.jar:?]

	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[org.eclipse.osgi-3.12.100.jar:?]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.6.4]

	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.6.4]

With OH 3.1.0.M2 it works fine.

Is there anybody working on this plugin? I have some issues during the setup of the binding:

I am using OH2.5 and have a very strange bug, as soon as I restart OH the connection to unifi is some how lost. OH states that the connection to the controler and the wifi client is “online” but OH does not get updates from the controler (i.e. if a wifi client is online it is not reported in OH). However, if I create a new wifi client thing, with the same mac number it works, and OH correctly reports that the client is online - so I have two things, with identical mac numbers, reporting different things. This results in that after a restart of OH I have to delete all the wifi clients and thereafter recreate them, then all clients are correctly reported in OH. Not very convinent.

Can I please get some clarification if anyone has the Unifi Binding working with a UDM Pro?

I see the GitHub Issue here was last discussed in January with no further update and above, while people mention it, I cannot find anything to say that they actually have it working.

@mgbowman, from what I can tell, is the main author but hasn’t mentioned this since his return in February and @pagm seems to have done some work on it but I can’t determine whether this was simply cloudkey configuration or actually relates to the UDM Pro

If you have it working can you please post what version of OH and the binding you are using?

Any info greatly appreciated since I broke my presence detection yesterday with the new UDM Pro install and now the coffee machine doesn’t turn on :sunglasses:

Cheers, Tim

I don’t have a UDM but I have been watching for future development of this binding. Have you seen this thread around UDM? UniFi Protect Binding (Cloudkey gen2+, Dream Machine Pro, NVR)

Unfortunately @swamiller, your link is to a totally different binding aimed at UniFi Protect video camera monitoring rather than this binding which provides UniFi Network device presence.

The confusion probably lies around the fact that both the Network and Protect modules run on a UDM Pro and these bindings can co-exist in OH to provide different functionality from them.

Definitely not working in OH3.0

UDM Pro and the UniFi Binding
I really, really want this binding to work with a UDM Pro so that I can get my phone presence detection back but I literally know nothing about Java development so fishing around in the binding code is beyond me.

But I have hacked together both a Powershell script and a Python script below that both work and return what I need to know - so I’m hoping that someone can take this and utilise it to add a UDM flag to the binding. Perhaps?


$udm = "https://unifi.local"
$staticURL = "/proxy/network/api/s/default"
$epLogin = $udm + "/api/auth/login"

$auth = @{
"username"= "myUsername"
"password"= "myStrongPassword"

$authResponse = Invoke-WebRequest -Uri $epLogin -Method Post -Body $auth -SessionVariable ubnt -SkipCertificateCheck
If ($authResponse.StatusCode -ne 200) {
    Write-Host "Authorization Failure"

$authHeaders = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$csrfToken = $authResponse.Headers.'X-CSRF-Token'
$authHeaders.Add("X-CSRF-Token", $csrfToken)

# Endpoints from https://ubntwiki.com/products/software/unifi-controller/api
# List of all _active_ clients on the site
$statusURI = $udm + $staticURL + "/stat/sta" 
(Invoke-RestMethod -Method get -header $authHeaders -uri $statusURI -WebSession $UBNT -SkipCertificateCheck).data | Select hostname, latest_assoc_time, mac, ip


import requests
import json
import time
import urllib3
#Disable warning of self-signed SSL Cert

udm = "https://unifi.local"
staticURL = "/proxy/network/api/s/default"
epLogin = udm + "/api/auth/login"
auth = {'username':'myUsername', 'password':'myStrongPassword'}

s = requests.Session()
resp = s.post(epLogin, data=auth, verify=False)
if resp.status_code != 200:

statusURI = udm + staticURL + "/stat/sta" 
clients = json.loads(s.get(statusURI).text)
for client in clients["data"]:
    if 'hostname' in client:
        hostname = client["hostname"]
        hostname = "hostname unknown"
    lastseen = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(client["last_seen"]))
    mac = client["mac"]
    ip = client["ip"]
    print(hostname + ", " + ip + ", " + mac + ", " + lastseen)

Cheers, Tim

After upgrade to OH3 I am missing “wired clients” and “site” support in this binding.
Is there any plans to get wired clients support in OH3?

From what I can tell, it kinda looks like both wired clients and site support were part of a branch that was never merged to main. This update added support for the latest authentication method for Unifi OS, but didn’t include the wired clients or site support in that feature branch. It also appears this is not being actively worked on so unless you want to hack it together like I’m doing, you’re SOL.

I don’t know if this is the right place to ask!

OpenHAB 3.1.0.M3
Unifi contoler 6.0.28 (on a Linux VM)
UniFi Binding latest

Has anyone managed to get this binding up and running for the use of presence detection?

Mark, thanks for info. I am not programmer, so I can’t hack this binding…

I have 3.1.0 M3 with the UniFi binding to match (not sure if by latest you mean a CI / snapshot version) hitting Unifi controller 6.0.45, doing wireless presence detection and providing data just fine.

I remember it stopped working when I went to M1 but I can’t remember what I did to fix it.

I do also have 3.1.0 M3 with the UniFi binding.
I connect to an Unifi controller 6.0.45 that is running on docker.
I’m also doing presence detection and it’s working fine.

My current setting looks like this:

Bridge unifi:controller:home "UniFi Controller" [ host="XXX.XXX.X.X", port=8443, username="abcdef", password="dontsayit",  refresh=10,  unifios="false" ] {
	Thing wirelessClient simonsPhone "Simon's Phone" [ cid="c2:e0:b5:9a:35:a0", site="", considerHome=180 ]
    Thing wirelessClient katrinsPhone "Katrin's Phone" [ cid="66:6a:a9:2f:d7:c1", site="", considerHome=180 ]
    Thing wirelessClient miasPhone "Mia's Phone" [ cid="8c:f5:a3:d2:7d:7d", site="", considerHome=180 ]
    Thing wirelessClient jurisPhone "Juri's Phone" [ cid="50:2e:5c:d0:be:50", site="", considerHome=180 ]
    Thing wirelessClient mariannesPhone "Marianne's Phone" [ cid="88:11:96:a3:fa:0d", site="", considerHome=180 ]   

That’s good to know. Then it is not for nothing that I am trying to find out why it does not work for me yet. :slight_smile:

How good of you to share a working configuration

I just updated openHAB from 3.0.1 to 3.1.0.M3 with UniFi controller 6.0.43 (on a CKG2+) and the binding is also working for me. I don’t know when they added this, but in the UniFi controller thing configuration there is a UniFi OS toggle. Once this option is enabled, the binding works smoothly (I think I restarted the binding once but it may just be me doing something else weird).

You may also want to double check that the toggle wasn’t overlooked like I did.

I thought UniFi OS was for Cloud Key or Dream Machine type devices?

I have the toggle switched off and all is working. I configured it through the UI so have no config to share though.