[PROJECT] Driver for Unifi Network Controllers

Darn. I will get that in tonight. Sorry.

EDIT:
Updated Version(s):

  • UnifiNetworkAPI.groovy = 0.4.19

Change(s):

  • Port Profile (portconf_id) is now included in the data that should be retained across port overrides.
1 Like

Works great! Port Profiles survive the Port State change. Thank you!

Glad to hear it worked on yours as well. It worked on mine so I figured it would... but further confirmation never hurts. Sorry for all the trouble with the port overrides to begin with.

Absolutely no need to be sorry. It's awesome that you have shared your time and creation with the community! I'm now saving several kWh of unneeded power by shutting down 2 APs and 2 switches every night during sleeping hours. All with the help of your driver. Thanks again!

1 Like

Are you using PoE powered switches like the Flex? Or are you using the Ubiquiti Plug or Power Strip?

I find those two to be a pretty amazing deal for how reliable they have been. Especially the strip. Control over 6 outlets individually plus a 7th for the USB-C ports? For <$50?! Yes please. Very reasonable especially considering how expensive most Ubiquiti stuff is (never mind the scalper horde)...

1 Like

I have a US-8 switch on my 2nd floor that is powered by PoE from my 24 port switch and also passes PoE out to an AP. So by killing the PoE to that port on the 24 port switch, I power down both the US-8 switch and an AP. Then, for the other AP, I use a Kasa KP115 (~$24) with a PoE injector.

I use your driver to power down the Unifi PoE port and the Kasa controller by djgutheinz to power down the 2nd AP, resulting in 2 APs and 1 switch going off (and back on in the morning.)

All of it works flawlessly! (Unrelated, but I also have a few Kasa HS300 power strips (also ~$50) that djgutheinz's app also controls perfectly.)

The reason I like the Kasa's is because they're also power monitors so they work with my Sense energy monitor AND I can pump that power data from Hubitat into InfluxDB and monitor my power usage over time with Grafana.

You can see in this picture that between about midnight and 7:30am, I power down several unneeded items with Hubitat, the Kasa driver, and your driver.

2 Likes

That is awesome! Thanks for sharing the information. I know many times people wonder "what can I use these drivers for..." and you just gave some pretty interesting AND easy to setup uses.

To be honest I never really gave much thought about my stuff like that... but I could certainly power down an AP or two at night as well. Some of my devices might get a much poorer connection but it is not like any of the ones that NEED a good connection would be operating at that time anyways. Something to give some more thought and planning to.

Thanks again!

2 Likes

Updated Version(s):

  • UnifiNetworkChild-Plug.groovy = 0.1.4

Change(s):

  • Somehow the Plug child was missing on/off commands. Not sure if I somehow accidentally deleted those at some point or some other mistake. This is now corrected.

Im struggling to even get a login to work...

I'm certain the Controller IP/Username/Password is correct, but it doesn't work. I even tried creating a local Admin account just for Hubitat but no joy.

The logs show an exception when performing login, with connection timed out

What am I missing?

Do you have the Unifi site in the preferences? It is usually "default" but if you have set it at some point you need to make sure that is correct as well.

Thanks ill check that :+1:

Something that just occurred to me - do the UDM and HE need to be on the same network? I've just got the UDM and I'm playing around with it a bit before I dismantle my existing Netgear-based network. But that means at the moment that my HE is not on the UDM network

They don't have to be on the same network, but you would need to be able to communicate from one to the other - routing through the Netgear router, might be a firewall rule to be adjusted to allow communication across networks (or just between HE/Unifi

2 Likes

Updated Version(s):

  • UnifiNetworkAPI.groovy = 0.4.20
  • UnifiNetworkChild-Presence.groovy = 0.1.3

Change(s):

  • Added support for the U6 Mesh access point (I have one myself and never realized I had not actually added support for it, oops), it will show up as one of the normal AP devices
  • Added additional attributes for Presence child devices. When the presence is now checked it will also indicate the Connected To MAC and Connected To Name attributes. These will let you know what that device is connected to, whether switch or access point. Thanks to @wafox for thinking of indicating what things are connected to...
  • Minor changes to the driver version update checking

I've rearranged my network a little and now the UDM and the HE are on the same network. Login appears to be successful :+1:

Now to start playing :wink:

Since this update, I am getting UnifiConnection - Request Timeout for any attempt to get presence, current stats, RefreshUnifiDevicesBasic, etc.
Login and ping status seem to work?

I don't /think/ my husband changed anything on the unifi side. Any ideas what could be causing this or where I should start to debug?

Edit to update this, husband installed an update and rebooted the unifi system and it seems to be working? I will continue to monitor

1 Like

Good to hear. Sorry I did not get a chance to reply to the original message, but at least it worked out anyways.

1 Like

I am getting a similar error for presence, but the rest seems to work
Capture

I understood that the driver would create child devices for my Ubiquiti APs, Cameras, etc

but despite having this set, I'm not getting any child devices created
image

All the drivers and Unifi firmware are up to date

This sounds just like what @forlornlawngnome had. Has there been an update for the controller lately, and did you reboot it after that?

For child devices you also need the respective child drivers on the Hubitat for them to be useful. Including the Presence child driver for presence detection. However, the error is more that it is not even getting to that stage.

Mine never showed failure to login, or anything worrying on that page except the last time it got the presence. The logs showed request timeout for presence, stats, decices,. Basically everything except long and login :woman_shrugging:.

Looking at update times, the controller did an update roughly 10 days ago, then I updated the hubitat code and broke things on the 22nd. We then applied updates again yesterday and it worked. I do know they released a new update for unifi just yesterday after we installed one so you might have new uodates