UniFi binding beta [3.2.0;3.6.0)

Another question. What is the right input for the poePort portIdx value? I’ve tried “gi2”, as my USW-16-PoE is reporting, but I receive the message

2022-02-28 14:10:35.332 [WARN ] [penhab.core.config.core.ConfigParser] - Could not set field value for field 'portIdx': For input string: "gi2"
java.lang.NumberFormatException: For input string: "gi2"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:?]
	at java.lang.Integer.parseInt(Integer.java:652) ~[?:?]
	at java.lang.Integer.valueOf(Integer.java:983) ~[?:?]
	at org.openhab.core.config.core.ConfigParser.valueAs(ConfigParser.java:215) ~[bundleFile:?]
	at org.openhab.core.config.core.ConfigParser.configurationAs(ConfigParser.java:128) [bundleFile:?]
	at org.openhab.core.config.core.Configuration.as(Configuration.java:79) [bundleFile:?]
	at org.openhab.core.thing.binding.BaseThingHandler.getConfigAs(BaseThingHandler.java:219) [bundleFile:?]
	at org.openhab.binding.unifi.internal.handler.UniFiBaseThingHandler.initialize(UniFiBaseThingHandler.java:66) [bundleFile:?]
	at org.openhab.core.thing.binding.BaseThingHandler.thingUpdated(BaseThingHandler.java:153) [bundleFile:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:154) [bundleFile:?]
	at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]

Any clue?

For the device I have it’s a number. Can you use openHAB discovery to find the ports and if you add such a port does it work? or does it also give the same error? In the later case it could be the port_idx is sometimes a number and sometimes a string. If that would be the case the binding needs to be fixed to handle strings.

It seems the number is working (so, we can say that this is not related to the config itself, as it should be “gi2”).

for enabling/disabling a port, you should use the channel “enable” right? what is the channel “cmd” goal?

thanks again

See the link to the readme in the first post in this topic.

After first try, everything’s working as expected.

But unfortunately, enable/disable a ssid triggers also a reprovisioning, and that is not fitting my use case. I would like instead to find a way to trigger a firewall rule with a switch … not sure if this is possible via rest-api, investigating

edit: perhaps I can use the “blocked” field … after 2 hours eg I can block the clients in the wlan for kids, instead of disabling the entire wlan


@hilbrand Really love this update and the opportunity to test this beta version that offers a lot more functionallity than the old binding.

In my network setup a cloud key G2+ runs the network application. While setting up the bridge i had to switch the port from 8443 to 443.

Maybe that is an information that helps someone.


Perhaps I’ve missed, but

Any chance to see if there are users connected via VPN?


It’s not available in the binding. Do you know where this can be seen in the data reported by the UniFi controller?

My guess is that it’s only reported by the Controller when you have a USG device in your network, as that’s the device that handles VPN connections.

@ariela Do you have a USG?

correct. but it should be configurable also in UDM Pro:

Ah, yes, I see. Is the UDM the more recent model compared to the USG? I’m not too familiar with either one. I just have switches and access points.

I’ll need to look into those UDMs a bit more, as my Zyxel firewall/router is getting a bit dated. :wink: Does the UDM also do site-to-site VPN tunnels.

Edit: Yep, sure does.

1 Like

there is a huge difference between USG and UDM Pro: UDM Pro doesn’t have the possibility to use the json file for extra configurations. But you can work around :wink:

I’ll receive my UDM Pro very shortly. I’ll let you know. Just ping me if you have questions about the “routing” side of the Moon :slight_smile:

Found it :slight_smile:

there is an interesting bunch of info you can collect by “stat/health”; in particular I see

  • if your system overall is ok (meta/rc)

  • Subsystem “wlan”: num_user, num_guest (num_iot is not clear to me), status, num_ap, num_adopted (good to set an alarm if the num_ap is different from num_adopted ;))

  • Subsystem “wan”: status, num_gw, num_adopted (good to set an alarm if the num_gw is different from num_adopted ;)). There is also gw_system-stats/cpu and mem that should be interesting

  • Subsystem “www”: status, latency, speedtest_ping

  • Subsystem “lan”: status, num_user, num_guest, num_sw, num_adopted (good to set an alarm if the num_sw is different from num_adopted ;))

  • Subsystem “vpn”: status, remote_user_active :slight_smile: also site_to_site_enabled should be interesting to add

Here you are: if there is a remote user connected via VPN, the remote_user_active is > 0. Otherwise is 0

:slight_smile: too much things to ask :slight_smile:

1 Like

I would suggest also to add from /stat/sysinfo:

  • version : representing the current software release installed in the controller

  • update_available : true/false

That would be great

1 Like

firstly, brilliant work with the beta binding! i’ve been trying it out the last couple of days and its working flawlessly.
Would it be possible to read out the number of wifi clients per wifi network? so for example i do have a separate iot network for all my smart devices and i want to know how many of them are connected, or if i have a separate network for guests but without using the “guest network” setting in the controller?

thank you for your brilliant work!

I finally just switched to the new beta binding. Great work thanks!

Is it planned to add access points as things in the future? I currently use the Art of Wifi PHP Library to activate/deactivate my access points at night time (or at least my wife does). This works great but I’m always trying to keep custom built stuff around OH to an absolute minimum and just stick with the regular bindings as much as possible.

@ariela Lot’s of feature requests :smile: It looks like these require new type of things and/or calling a different api on the controller. Because the forum here is not a convenient place to track larger change request. I’d like to suggest if you can please create an issue on the openhab-addons GitHub repository issue tracker. Add a list of the features, grouped by: openHAB thing - openHAB channel - UniFi data field - Description of the channel. The more clearer the requirements are the faster I can add them.

@ariela , @N20VSLS I’ll add 2 channels to the wlan thing: number of wirelessClients and number of guestClients.

@DrRSatzteil activating the access point itself is not possible currently. I also don’t know and would need to find out the api call needed to activate/deactive the ap. If you have more information on that please post it here. There are some possible alternative solutions, but I’m not sure if they do work for you: 1) If you power the AP via a PoE port you can disable the power to the port, effectively shutdown the AP. But this might be a bit of brute force method. 2) It’s possible to active/deactive a network via a wlan thing. This can disable the whole WiFi network, not specifically a AP. So that might be a bit to much.


As I’m currently using the Art of Wifi client (GitHub - Art-of-WiFi/UniFi-API-client: A PHP API client class to interact with Ubiquiti's UniFi Controller API) let me share the implementation of this project with you. The activation/deactivation works like that:

public function disable_ap($ap_id, $disable)
        if (!is_bool($disable)) {
            return false;

        $this->curl_method = 'PUT';
        $payload           = ['disabled' => $disable];
        return $this->fetch_results_boolean('/api/s/' . $this->site . '/rest/device/' . trim($ap_id), $payload);

Oh and regarding you other suggestions: unfortunately my POE switch isn’t a UniFi one so this is not an option for me. And disabling the wifi networks does not disable the radio afaik. So disabling the device seems to be the way to go for me.

1 Like

Finally got around to installing the latest version. Had been running the released version. All working well.

Thanks for your excellent work on this binding @hilbrand!

1 Like

I see the WLAN thing has a channel for a QR code for joining the WLAN network. I’d love to be able to display a QR code for joining the guest network. Just wondering if anyone has already done the work to create the QR code.

If not, I’ll take a look at it. I seem to recall there’s a Linux command to create a QR code, so should be easy enough.

1 Like