UniFi binding beta [3.2.0;3.6.0)

@ccutrer the ‘normal’ port will probably be ome q new thing. It looks like these options are user configured values. So I need to find out where these are and what command is done.

@DaveL this logging doesn’t include any of your previous log lines. Making it difficult what’s wrong. The log seems to complain about json format. I suspect it’s because it gets some html page, instead of a json api. are your sure your talking to the api?

@ariela I hope to get it in the next milestone, but need to make some small changes. But until then you can always install the marketplace version.

Quite strange, but I’m not able to see the binding in the marketplace anymore (after I’ve migrated from snapshot to milestone M3) :frowning:

I’ve installed the manually (I hope this is the latest)

I really do not know. I point back to my original question…which host IP address should I be pulling from my UDM-Pro? I’m not a network guy; I purchased the UI gear for the versatility and am learning as I go. Should I select the Gateway IP for the subnet that my OpenHAB controller is residing on? Some other IP address?
I have tried just about every combination of host IP/port/unifios settings I could. The closest I’ve gotten to what seems like success is selecting the gateway IP for my primary LAN (not where my openHAB server resides), port 443, unifiOS=false (which still strikes me as odd) and I get:

2022-04-24 10:19:31.380 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'unifi.things'
2022-04-24 10:19:31.410 [WARN ] [i.internal.api.model.UniFiController] - Not Authorized! Please make sure your controller credentials have administrator rights
2022-04-24 10:19:31.411 [INFO ] [openhab.event.ThingStatusInfoEvent  ] - Thing 'unifi:controller:home' updated: ONLINE
2022-04-24 10:19:31.411 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'unifi:controller:home' changed from OFFLINE (CONFIGURATION_ERROR): Unknown HTTP status code 404 returned by the controller to ONLINE
2022-04-24 10:19:31.411 [INFO ] [openhab.event.ThingStatusInfoEvent  ] - Thing 'unifi:wirelessClient:home:DavidsPhone' updated: ONLINE
2022-04-24 10:19:31.411 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'unifi:wirelessClient:home:DavidsPhone' changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE
2022-04-24 10:19:31.412 [INFO ] [openhab.event.ThingUpdatedEvent     ] - Thing 'unifi:controller:home' has been updated.
2022-04-24 10:19:31.422 [WARN ] [.handler.UniFiControllerThingHandler] - Unhandled exception while refreshing the UniFi Controller unifi:controller:home - Unknown HTTP status code 404 returned by the controller
2022-04-24 10:19:31.423 [INFO ] [openhab.event.ThingStatusInfoEvent  ] - Thing 'unifi:controller:home' updated: OFFLINE (COMMUNICATION_ERROR): Unknown HTTP status code 404 returned by the controller
2022-04-24 10:19:31.423 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'unifi:controller:home' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Unknown HTTP status code 404 returned by the controller
2022-04-24 10:19:31.423 [INFO ] [openhab.event.ThingStatusInfoEvent  ] - Thing 'unifi:wirelessClient:home:DavidsPhone' updated: OFFLINE (BRIDGE_OFFLINE)
2022-04-24 10:19:31.423 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'unifi:wirelessClient:home:DavidsPhone' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)

Which would seem to indicate that I’m at least seeing the Unifi controller?
Update: actually the log errors are all over the place. I can now get the same error using a host IP of that on the subnet that openHAB is residing. I’ve tried the same configuration multiple times and gotten different log entries; they are never consistent. But I am now seeing this entry:

2022-04-24 10:59:02.158 [INFO ] [.internal.api.UniFiControllerRequest] - UniFi returned a status code 499: {
  "errors": [
    "2fa token required to authenticate to SSO"

The error suggest your UniFi controller has 2 factor authentication enabled, which is not supported by the binding. Did you enable 2 factor authentication, does it ring any bells?

I see if I can find out why it reports the thing online, but actually isn’t. Looks like the binding concludes it can access the device with certain replied data, but actually can’t. This won’t help you for now.

The IP address to be used should be to the device running the UniFi controller software.

Holy Smoke, that was it! With 2FA disabled the Unifi controller is now showing as ONLINE with Port=443 and unifios=true. Items seem to be reporting correctly, will do more testing tomorrow.
Thank you again for the support, it’s greatly appreciated.

Well, not sure how, but I’ve active the 2FA in my UI account, and I don’t have any issue in receiving the info from the UDM-PRO. just migrated from USG-3P/Key v.1, and I’m absolutely happy :slight_smile:

1 Like

@hilbrand I’m experiencing a strange issue. I’m migrated my production openhabian from snapshot to M3 (now M4), and I’m not able to see the Unify Binding (Beta) in the marketplace anymore.

I’ve installed the jar manually in the addons folder.

Any clue?

Small update. I’ve made some changes, also related to the review process, and expect the related pr to be ready to being included in the official release. There are 2 interface changes:

  • (wlan) Renamed channel xPassphrase to passphrase.
  • (poePort) Renamed config parameter portIdx to portNumber

If you get the latest version of this binding (uninstall and install market place binding). And If you had created a wlan or poePort thing via the UI you need to recreate the thing to get the updated changes to the thing. When created manually you need to change your text files.

1 Like

3.3.0 M6 issue fixed (don’t know how, but now it works like a charm)


i love this binding! Exactly what OpenHab needed to take advantage of UniFi’s great features!

The installation and setup were successful (have the above linked .jar in the addon folder)

Unfortunately I also have the problem “COMMUNICATION_ERROR” about every 10 seconds. The following error is written in the logs:

Thing 'unifi:controller:home' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Parameter 'upper' (0) is less than or equal to 'lower' (0) parameter.

Which parameters are meant here? Does anyone know this problem?
Thanks very much!

I don’t recognize the message from the binding. However a search in all openHAB code gives this message for the range profile. Did you add this profile without lower and upper configuration?

In fact, I had briefly tested the range profile. I wanted to try to set a switch depending on the number of guests in the WiFi. Unfortunately that didn’t work at all.

The configuration looks like this:

Switch unifiGuestPresent  "UniFi Gäste"  <switch>  (unifiNetwork) {channel="unifi:site:home:homeSite:guestClients" [profile="system:range", lower="-1", upper="1", inverted="false"]}

Also unsuccessful was:

Switch unifiGuestPresent  "UniFi Gäste"  <switch>  (unifiNetwork) 
 {channel="unifi:site:home:homeSite:guestClients" [profile="system:hysteresis", lower=1, inverted="false"] }

I’m assuming you want it on when there are guest clients? Did you try something like this:

Switch unifiGuestPresent  "UniFi Gäste"  <switch>  (unifiNetwork) {channel="unifi:site:home:homeSite:guestClients" [profile="system:range", lower=1, upper=100]}

Hey Hilbrand, thank you very much for your fast reply.

I tried your suggestion, but it results in the following error:

Exception while formatting value 'OFF' of item unifiGuestPresentProfile with format '%.0f': f != java.lang.String

Adding [%s] to the items name so it looks like this "UniFi Gäste [%s]" fixes this error.

Thank you again :slight_smile:

First of all, thanks a lot for this great binding.

I am currently trying to switch on/off the power delivery for some of my poe ports. I think I have a workaround but there is still something strange.

I have the following items:

String PoePort_4_Hotspot_EG_Mode             "Port4:  Hotspot EG: Modus [%s]"                              { channel="unifi:poePort:home:poePort4:mode" }
Switch PoePort_4_Hotspot_EG_Enable           "Port4:  Hotspot EG: Poe Enabled"                             { channel="unifi:poePort:home:poePort4:enable" }

looking at the “enable” channel of the “poePort” it sounds like I could use this: “Enable Power over Ethernet”

But when I use the switch item and try to turn it off I get the following output:

2022-07-19 22:17:56.489 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'PoePort_4_Hotspot_EG_Enable' received command OFF
2022-07-19 22:17:56.492 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'PoePort_4_Hotspot_EG_Enable' predicted to become OFF
2022-07-19 22:17:56.498 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PoePort_4_Hotspot_EG_Enable' changed from ON to OFF
2022-07-19 22:17:56.664 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PoePort_4_Hotspot_EG_Mode' changed from auto to off
2022-07-19 22:17:56.666 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PoePort_4_Hotspot_EG_Enable' changed from OFF to ON

The mode gets changed to off which sounds reasonable. But right after that the enable item jumps back to on.
It seems that the port is actually turned off. The mode is off and my device is off. Still, the switch is back at on and I have to turn it off a second time before I can turn it on again.

Enabling it looks similar:

2022-07-19 22:24:10.304 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'PoePort_4_Hotspot_EG_Enable' received command ON
2022-07-19 22:24:10.306 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'PoePort_4_Hotspot_EG_Enable' predicted to become ON
2022-07-19 22:24:10.310 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PoePort_4_Hotspot_EG_Enable' changed from OFF to ON
2022-07-19 22:24:10.488 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PoePort_4_Hotspot_EG_Mode' changed from off to auto
2022-07-19 22:24:10.489 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PoePort_4_Hotspot_EG_Enable' changed from ON to OFF

It seems when I use it from rules it would work if I just send the command without checking the state before, but it feels a bit strange…

I see the same behavior. But there seems to be a time lag. When I switch, it switches right back in openHAB ui. But it does actually switch, and openHAB will show the right state. It just takes some time. I didn’t check yet if the delay is in the binding or if it’s the UniFi controller that takes some time to update the API. @markus_pfleger do you see this behavior too?

Hey Guys,
I saw that the UniFi binding is now supporting switching on/off POE over Openhab.
The Biniding wants a PortIndex or Port Number and a MAC Adress. Where can I find these Values? I have two Switches. USW-24-G2 & USW-16-PoE.
Thanks for your help!

You can find these values in the UniFi controller on the page of the device. The port number is just the physical number of the port.

So the MAC Adress is the Adress of the Switch and the Port number is the Port?

Yes. The mac address of the switch and port number of the port. If you have configured the controller in openHAB the discovery scan should be able to find the ports.