Ubiquiti Unifi Binding Feature Discussion

Hi all, sorry I haven’t been very active here - been super busy IRL. Going to be away for the next 2 weeks, but when I get back I’ll be more active in getting the binding polished up and pushed into master.

Cheers!

4 Likes

Great thanks for the work.

Hi,
I’m using another way for presence detection but would be interested to use this binding for another use-cases:
Turn the wifi off when I’m absent and turn it on when I’m back.
This is not possible, yet, right? If I’m right, do you consider doing it with the “polished” version?

Thanks,
Michael

How would you notice you’re back at home when your mobile device isn’t able to connect to your WiFi (because it’s disabled)? WiFi has to be enabled for your device to connect so the binding can detect you’re home.

You can download the current build from https://jenkins.otr.mx/job/openhab2-unifi-binding/lastSuccessfulBuild/artifact/addons/binding/org.openhab.binding.unifi/target/org.openhab.binding.unifi-2.2.0-SNAPSHOT.jar. I’m using it with openHAB 2.2.0 without problems.

1 Like

I’m just doing tests around this solution:

Regards,
Michael

There are indeed lots of different solutions but of all the ones I tried out I find this Unifi one works best for me. It works flawlessly while not impacting battery life.

Of course one should not turn off WiFi when away … but I don’t really see why I would want to do that anyway. I have to many always on WiFi devices in the home.

What’s your concern or reason to turn off WiFi, security ? Power usage ?

Verstuurd vanaf mijn iPhone

Hi Rohnny,
these are exactly my “concerns”. Security, Power Usage and radiowaves. I don’t have any devices that are “always on with wifi”. Don’t get my wrong: I didn’t want to start a discussion around what the pro’s and cons for that binding are or that kind of presence detection.
It was just a simple question because I own three access points and i’m looking for a way to turn the WIFI ON and OFF automatically.
So perhaps @mbr or @mgbowman can answer the question if it’s planned to have that capability.
Thanks,
Michael

I too have found this binding to be the only reliable method for presence detection. If you’re going to rely on another method to determine that someone has arrived home, you may as well use that same method to determine when people have left and not complicate things.

Personally I don’t think there’s a good reason to turn wifi off, even when you’re away. If your network isn’t already secure, turning it off for a few hours a day is going to do little to mitigate that. Power usage for an access point is hardly worth worrying about. If no one is home, who exactly are you concerned about being exposed to radio waves?? :wink:

As far as the capability of the binding, it’s already as capable as it ever will be for your use case given that if there is no wifi available, it will have no way of detecting presence. You could already use it to turn off the wifi if you wish. When the last device drops off, kill the wifi.

There are options to schedule the availability of the different SSIDs in the UniFi controller software. I don’t think it is in this binding though. I think it would depend on whether this is exposed in the controller’s API.
I think this is probably the closest to what I think you want.

  1. Click the Settings icon in UniFi (lower left)
  2. Click Wireless Networks.
  3. Click Edit for the SSID you want to schedule.
  4. Expand the Advanced Options.
  5. Check Enable WLAN Schedule.
  6. Change the settings to your desired schedule.
  7. Click Save at the bottom of the page.

Thanks Eric. I’m already using this to switch off the WIFI during the night. If I refer to others using the API (e.g. PHP https://community.ubnt.com/t5/UniFi-Wireless/PHP-class-to-access-the-UniFi-controller-API-updates-and/td-p/1512870) there seems to be a method called “disable_wlan”.
While typing, perhaps I will try implementing this into the binding if @mgbowman is OK with it.

I’m stumped. I can’t get it to work. My device and bridge are online but I’ve got no phone data.

Rather than make assumptions, I have some questions:

In the bridge Thing:

  • The binding readme does not include the ‘@ “Unifi”’ but all the examples do. Which is correct?
Bridge unifi:controller:home "UniFi Controller: home" @ "Unifi" [ host="xxx.xxx.xxx.xxx", port=8443, username="xx", password="xxxxxxxx", refresh=10, considerHome=180 ]

or

Bridge unifi:controller:home "UniFi Controller" [ host="xxx.xxx.xxx.xxx", port=8443, username="xx", password="xxxxxxxx", refresh=10, considerHome=180 ]
  • Is the host the IP address of the network gateway or the PC/Server where the controller software resides? My gateway is not Unifi. Does this make a difference?

  • Does the mac address in the client Thing have dot, comma or colon separation?

  • I set my Unifi Site Name as ‘home’ and the Controller name as ‘home’ as I’m unclear in the thing and item definitions which goes where. Was this wise?

  • In the Unifi Controller settings, what should be in the Controller Hostname/IP setting and how does this relate to the Thing and Item Files?

Sorry for the questions.

Thanks!

both are correct. The @Unifi part just adds another tab in the control section of PaperUI and it’s optional

The host running the Unifi Controller Software.
Gateway can be anything. It doesn’t have to be from Ubiquiti Networks. It simply won’t be managed from the Unifi Controller S/W.

colon

that should be fine. I use another name for the Controller.

those settings (https://IP:8443/manage/site/default/settings/controller) on the Unifi Ctrl S/W should be set automatically by your system. They are for the local controller (and should be the same as for the Thing defined in OH2).

Here is my example config:
/etc/openhab2/things/Unifi.things

Bridge	unifi:controller:Unifi_HomeR	"Unifi Controller: HomeR" @ "Unifi" [host="172.16.13.100", username="xxxxxx", password="yyyy", port=8443, refresh=10]
{
	Thing	client	XXXXXs_S8	"XXXXXs_S8" @ "Unifi"	[mac="04:d6:aa:87:4c:25", site="default"]
	Thing	client	YYYYYa_I6	"YYYYYa_I6" @ "Unifi"	[mac="a8:66:7f:e3:ac:ca", site="default"]
}

/etc/openhab2/items/Unifi.items

Contact		XXXXXs_S8_PRES	"XXXXXs S8 Presence [MAP(Unifi.map):%s]"	<switch>			(gUnifi)	{channel="unifi:client:Unifi_HomeR:XXXXXs_S8:online"}
Number		XXXXXs_S8_RSSI	"XXXXXs S8 RSSI [%s]"						<qualityofservice>	(gUnifi)	{channel="unifi:client:Unifi_HomeR:XXXXXs_S8:rssi"}
Number		XXXXXs_S8_UPTM	"XXXXXs S8 Uptime [%d]"						<time>				(gUnifi)	{channel="unifi:client:Unifi_HomeR:XXXXXs_S8:uptime"}
DateTime	XXXXXs_S8_TIME	"XXXXXs S8 Last Seen [%1$tH:%1$tM:%1$tS]"	<time>				(gUnifi)	{channel="unifi:client:Unifi_HomeR:XXXXXs_S8:lastSeen"}

Contact		YYYYYa_I6_PRES	"YYYYYa I6 Presence [MAP(Unifi.map):%s]"	<switch>			(gUnifi)	{channel="unifi:client:Unifi_HomeR:YYYYYa_I6:online"}
Number		YYYYYa_I6_RSSI	"YYYYYa I6 RSSI [%s]"						<qualityofservice>	(gUnifi)	{channel="unifi:client:Unifi_HomeR:YYYYYa_I6:rssi"}
Number		YYYYYa_I6_UPTM	"YYYYYa I6 Uptime [%d]"						<time>				(gUnifi)	{channel="unifi:client:Unifi_HomeR:YYYYYa_I6:uptime"}
DateTime	YYYYYa_I6_TIME	"YYYYYa I6 Last Seen [%1$tH:%1$tM:%1$tS]"	<time>				(gUnifi)	{channel="unifi:client:Unifi_HomeR:YYYYYa_I6:lastSeen"}

/etc/openhab2/transform/Unifi.map

OPEN=Away
CLOSED=Home
NULL=Unknown
1 Like

Many thanks for answering all my questions.

Unfortunately the binding seems to have wrecked my OH system and despite getting rid of it all, clearing caches etc, it still won’t start, giving:

2018-01-15 20:41:03.981 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-binding-unifi, openhab-misc-myopenhab': Error restarting bundles:
	Exception in org.eclipse.smarthome.io.rest.sse.internal.SseActivator.start() of bundle org.eclipse.smarthome.io.rest.sse.

So I need to investigate this first but thanks.

Dim,

It’s all working now, My openHAB seemed to sort it self out a bit overnight and I just needed to uninstall and re-install a couple of bindings (MQTT and Transformation service) and then re-install the unifi binding and all the items for my phone had active values.

Thanks again.

1 Like

What are the security implications of providing access of Unifi controller to an IOT device?

What do you mean?

This binding is engineered to be “read only”. It simply pulls data from the Unifi Controller on a predefined period.
It does not modify the settings of the Unifi Controller software.
You could also create a new User with Read Only role on the Unifi Controller software to be used for this binding to connect and pull info.

Thanks for clearing that up.

I setup the Unifi binding and all the items are shown in the sitemap correctly except LastSeen. The log says

2018-02-01 19:32:47.619 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'PhoneLastSeen' for widget org.eclipse.smarthome.model.sitemap.Text
2018-02-01 19:32:47.627 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Text

Any idea what could be the issue?

a typo either in your sitemap or items file
post them so we can check them. Some log entries alone do not show the full picture :slight_smile: