[PROJECT] Driver for Unifi Network Controllers

Updated Version(s):

  • UnifiNetworkAPI.groovy = 0.4.79

Change(s):

  • Added recognition for the Cloud Gateway Ultra (thanks to @user588 for the model). It should use the same child driver as the Cloud Gateway Max (the UnifiNetworkChild-UCGMax.groovy) as they appear to have the same port hardware and features (from what these drivers can do).
  • Altered the way Events are processed to remove the "Forced" functionality. This means that I will no longer force an event to state that it is "isChanged". It is now totally reliant on the Hubitat's underlying determination. I also changed the trace logging in this area to remove the Forced portion but be more specific if there is a unit or description associated.
  • Added some additional data response handling.
1 Like

Awesome I was literally coming here to post something about this as I am getting a bunch of "forced" events for the same value.

One request for your consideration is an option to suppress the Uptime* and LastSeen event updates. Personally all I care about is if a mobile device is present or not, no further details. With presence check turned on these come quite frequently and I personally don't have use for them so trying to reduce the event load on my hub. You could consider making a new preference that allows users to enable/disable the tracking of these updates.

@snell updated to the latest 0.4.79 version and something is still messed up with the Connected To Mac update. Events are being "forced" every minute even though my phone is connected to the same AP/MAC.

The Forced piece is gone, from the parent and anything it sends to the children... so there might be something on the Hubitat side that it does not recognize that type as changing or not? Not sure.

Even if I do not "force" it by specifically setting the "isChanged" flag, the sendEvent function that Hubitat will still automatically decide whether to make that true or false on their own...

@snell figured it out, in the version history v0.4.51 you mention:

"Connected To MAC" to "ConnectedToMAC", "Connected To Name" to "ConnectedToName", and "Signal Strength" to "SignalStrength" to fix visual error on device page(s)

But I found several references to "Connected To MAC" within the code which I assume need to be updated. For example on line 1790 TempMap is declared using "ConnectedToMAC" but then on 1810, 1814 , 1840, and 2266 "Connected To MAC" is being used with TempMap instead.

But specifically changing lines 1876 and 1932 from

PostEventToChild( "Presence ${ ClientMAC }", "Connected To MAC", ConnectedMAC )

to

PostEventToChild( "Presence ${ ClientMAC }", "ConnectedToMAC", ConnectedMAC )

fixed the issue because the child presence driver uses ConnectedToMAC attribute.

In the meantime I added the following to the PostEventToChild function:

if (["Uptime","UptimeDays","UptimeHours","UptimeMinutes","UptimeSeconds","LastSeen"].indexOf(Variable) > -1) return

Would be awesome if you would be willing to have an optional preference to suppress these.

Having trouble getting my G4 Doorbell (POE) to show events or log anything when the doorbell is rang. I have a Dream Machine SE What am I doing wrong?

I've installed the Unifi Protect API & UnifiProtectChild Doorbell drivers. I then configured it and confirmed it can connect (using a non MFA local admin account):


image

It creates the doorbell child on its own, and all seems well, but whenever I press physical button on the doorbell, I get nothing in my logs or events. What am I doing wrong? I assume I'm a moron, but I can't figure out why I'm a moron.

This should be handled over in the Protect project thread, not the Network one. I have posted with some questions/feedback over there.

1 Like

Updated Version(s):

  • UnifiNetworkAPI.groovy = 0.4.80

Change(s):

  • Corrected multiple Connected To MAC/Connected To Name/Signal Strength instances that somehow still existed with their spaces... Now the only ones left are in the revision history.
  • Added a Preference on the parent that will allow you to disable Uptime event reporting (including the sub-divided ones like Uptime Hours, Uptime Minutes, etc...) for all devices EXCEPT ClientCheck. It is enabled by default (and if you do not set it, they will still be reported so people do not need to Save Preferences unless they want to disable it for this). I debated about doing this per-child but I do not want to have to edit EVERY child driver for this, so it went in the parent. But CheckClient only happens every hour, so there should not be any impact to leaving the Uptimes within it.
  • Updated and added some descriptions to some of the Preferences.
1 Like

@snell Thank you very much for the last update! You have added several enhancements to this driver, any way I can buy you a beverage of your choice?

Just updated and all good except I do still have LastSeen every minute but all good if you don't want to restrict it with the new EnableUptimeEvents preference. Another idea is to make the LastSeen a state variable instead on the child device. I have seen and worked several community drivers where that was moved from an attribute to a State variable.

Updated Version(s):

  • UnifiNetworkAPI.groovy = 0.4.81

Change(s):

  • Included LastSeen events as being related to the UptimeEvents, as it makes sense that they would be closely identified with each other. They should no longer be updated if the EnableUptimeEvents is disabled.
  • Also fixed a bug in the placement of some of the events I saw, that has apparently been long-standing. If you performed a manual presence it may have created a Presence child for that... which it should not do for just immediate manual attempts. It SHOULD update an existing Presence child that is listed on the MAC Presence preference.
1 Like

It seems UDM 4.2.8 and network 9.1.118 fixed the issue for me. One of the bugfixes in Network 9.1.118 was " * Fixed an issue where clients connected to aggregated ports could trigger false connect/disconnect system logs." I suspect that could have been the cause as I have a 2 ISPs.

1 Like

Interesting... Thanks for letting me know.