[PROJECT] Driver for Unifi Network Controllers

Unless I am missing something... Actuator is already listed as a capability and has been for a while. Your screenshot shows it as well.

Apologies - I was editing another community driver and added it to that one, then when I made a mental note of who to mention it to, I thought it was yours, but you're completely right.

1 Like

:slight_smile:
No worries at all. You had me double checking... because almost ALL of my parent drivers have Actuator.

I just did a downgrade and restore to a slightly older controller version. I did this via ssh into my cloud key. I then discovered that my HE database was suddenly insanely bloated. Is there any chance that since the two are connected, something could have gone wrong and s spilled over?

I am not sure how. The driver can create a lot of logging data if you have it set for Trace, but it would still be based on your refresh rate and the stats received from the Controller.

Did you check the Runtime Stats to see what was creating the most activity?

Of course... I really do not know what makes up the Hubitat database or how it can grow so much at times (or why it seems to grow suddenly). That might be a question for @gopher.ny...

1 Like

The growth appears to be triggered by some form of concurrent write to the database. I'm saying "some form" because concurrent writes happens all the time, yet incessant growth is triggered infrequently. Something makes H2 database engine think it can't reuse allocated space on one or more tables, and it starts allocating new space every time data is inserted/updated. Overall data volume remains low compared to database size. Compact or backing up and/importing shrinks it right down.

With 2.2.8 providing more feedback than previous versions, I've identified a couple of places where this can happen and made changes in upcoming 2.2.9, hopefully it solves the issue for good.

I'm looking at the options of database engine update or using a different engine entirely, too, but definitely not in 2.2.9.

7 Likes

Thank you so much for everything you do.

1 Like

@snell I notice there is variable labeled "wan health" Is this exactly as it sounds? Can I use this reliably to monitor internet connection? I am using web pinger but it would be great to have a "second opinion" of sorts.

I would assume so. It is exactly as reported by the Unifi controller. I have only seen the values of "ok" and "unknown" for health values (unknown for the vpn, since I am not using it) so I do not know what other ones it might report (although I would expect anything OTHER than ok would probably be bad news for the wan).

1 Like

@snell

Nice work. Enjoying the progress. I noticed that with MFA enabled I get the login error. Disabled no issues. When you have time can you look into adding the MFA option for login. Willing to test if needed.

Thank you

Have not looked at MFA since I keep mine local and if they are in my network I am messed over already.

But I will try to look into it. Focused on my upcoming "major update" at the moment, so it will not be before that.

1 Like

You can use MFA for remote/mobile and use a local admin account for HE.

That’s what I do. Works great.

Updated Version(s):
UnifiNetworkAPI.groovy = 0.4.0
UnifiNetworkChild-Presence.groovy = 0.1.0
UnifiNetworkChild-UDMP.groovy = 0.1.0
UnifiNetworkChild-UDM.groovy = 0.1.0
UnifiNetworkChild-AP.groovy = 0.1.0
UnifiNetworkChild-RPS.groovy = 0.1.0
UnifiNetworkChild.groovy = 0.2.2

Change(s):

  • This is a MASSIVE change to my Unifi Network drivers. Child devices have been massively reworked. So let me try to go through it from a high level at least:
    • The UnifiNetworkChild.groovy is no longer the primary child device most people will use. Those functions have been replaced by the UnifiNetworkChild-Presence driver. If you use automatic presence detection you would use the new driver. I recommend that you REMOVE the existing child devices so they will be correctly renamed and generated with the correct driver. I apologize for those that this will impact with Rules... but this should be a one-time thing.
    • There are now a slew of additional child drivers as listed above. These are optional but will be needed if you enable the "Unifi Children" preference. When you do so, the parent will generate child devices based on the Unifi devices that are connected to the controller. It will perform a check for this once a day. You can speed the process by running the RefreshUnifiDevices command in the parent. It can be a large data response... so give it a bit.
    • Each of the new child devices are intended to provide additional preferences specific for the devices it handles, additional commands, and additional data to display. They are all still works in progress at this time but I wanted to get it out there for people to start using. Examples of new features already included are the ability to set the color of an access point's status LED (the ring on most newer APs or the indicator on the in-wall versions), activate the locate function (so that LED blinks), enable/disable ports on the Redundant Power System, etc...
    • Disabling the Unifi Children preference will delete all children EXCEPT Presence-based children.
    • All of the child drivers have the Actuator capability (although a couple do not have special commands yet) so that whatever commands they do have (or get) will be able to be triggered otherwise (like with Rules). This will make it possible for people to use the AP status LEDs in conjunction with their Hubitat system readily, for yet another method of having a warning or "all good" status around (as an example).
  • Far less important are changes to the driver version handling.

Note(s):

  • Like many of my drivers, if anyone has additional Unifi devices that I do not (and I have few) AND they would be willing to share data that is returned, I would appreciate it. It will be FAR more difficult for me to implement commands for devices I do not have access to but at least I can get data for them implemented.
4 Likes

Snell - thanks so much for these drivers - very cool stuff. One possible request and another heads up:

Request - I'm still not sure exactly what I would use it for, but could/should there be a driver for UnifFI Switches? I have a USW 48 Pro PoE and your code seems to think it's an RPS.

Heads Up - I initially installed the drivers manually, but then ran a match on Hubitat Package Manager. When it "updated", it overwrote the AP driver to the RPS driver. Something seems to be mismatched there. I'm not sure if you have any control over that or if the HPM guys need to tweak something.

There is not a driver yet for a switch, because I do not have any and could not base it on anything. It should not have detected as an RPS though (darn). I will have to check the code about that, because it bases it on the model returned. Hopefully I did not pick TOO generic of a field...

As for HPM... Ugh. I will look at that as well. I am SURE I must have made a goof in the manifest file needed. I also lost the desktop (graphics card died) I was using for the extra steps HPM requires... So I need to get that set on something else.

I should be able to get those both fixed tonight, so thanks for letting me know! I appreciate any feedback (good or "constructive").
:grinning:

Updated Version(s):

  • UnifiNetworkAPI.groovy = 0.4.1

Change(s):

  • Corrected detection of switches, although almost everything will be unidentified (and thus just dump their data to Debug logging if that or Trace is enabled). Turns out the RPS (and others) are identified as type USW, so I had to get more specific by checking the model identifier after that. RPS should now be correctly identified and others (as stated) will dump to Debug. If someone wants to provide that information to me (in a PM) I can start adding support.
    If you had a device that was incorrectly identified (@ottojj) then you can Remove that device and it should NOT be recreated when the next UnifiDeviceRefresh is performed (but there will be the aforementioned log if the correct level is enabled).

Note(s):

  • HPM should now be fixed... At least to the extent of all the drivers should properly be identified and have ID numbers properly and such.

If I have a Cloud Key Gen 2+ which one of these would I use? It's still running the new Unifi OS software.

@markbellkosel84:
You would use the UnifiNetworkAPI.groovy driver for anything. The other drivers are if you use the automatic Presence feature and/or if you enable the Unifi Children feature to detect/use other Unifi devices. I do not have any specific detection for the Cloud Key but the Unifi Controller (whatever is hosting it) is what the parent connects to, so that should not matter.

Below applies for anyone with added devices:
If you want specific device data/features... I will need to add support and a specific driver. The best method for the data is to set the parent to Debug logging, then run the UnifiDeviceRefresh and PM me the logged data. Specific commands and features beyond the data are more difficult (if I do not have a device) but CAN be worked over time.

Devices I plan on adding:
Smart Plug
Smart Power Strip (on the way)
Basic Switches (I have a couple small ones on the way)

Plus I plan on adding more features to the existing specific devices, as I try them out. This is just an unpaid hobby though... So it takes time.

1 Like

Thank you for the clarification. I was just not sure about the selection in the preferences but I have left it on other and it seems fine.

Updated Version(s):

Change(s):

  • Unifi Smart Plug has had initial support added. Smart Plug will be identified and a child device created (if UnifiChildren is enabled). Plug can be controlled for on/off as well as power cycling the outlet. Has the Outlet capability so it has the switch attribute to show on/off.
  • Updates to device identification method. It now works on the device model no longer the returned type (the plug proved the type was a mess, because it was showing as an AP just like the access points).
1 Like

@snell - You Rock! I have several of the plugs connected to different devices and just got some of the new power strips. I will get new driver installed and happy to provide any feedback for you. If you needs specific testing, i have:

  • UDM Pro
  • 24 Port POE Gen 2
  • 16 Port POE Gen 1
  • 8 Port POE 60Ws
  • 5 Port Flexs
  • Nano APs
  • UAP-AC-M's
  • Plugs
  • Power Strips