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.
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]
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
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.
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?
Powershell:
$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"
Exit
}
$authHeaders = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$csrfToken = $authResponse.Headers.'X-CSRF-Token'
$authHeaders.Add("X-CSRF-Token", $csrfToken)
$authHeaders.Add("Content-Type","application/json")
# 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
Python3:
import requests
import json
import time
import urllib3
#Disable warning of self-signed SSL Cert
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
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:
exit()
statusURI = udm + staticURL + "/stat/sta"
clients = json.loads(s.get(statusURI).text)
for client in clients["data"]:
if 'hostname' in client:
hostname = client["hostname"]
else:
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)
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 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.
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.