[PROJECT] Driver for Unifi Network Controllers

update!

APs childs were re-created automatically and they work fine, label is also set right ! Thanks

only thin I see is the presence Label updating from the controller - no really big deal :wink:

Thanks !

Thanks for updating and checking so quick!

As for your questions:
Version shown in the driver Current State (or State Variables) will not update until it does the Daily Check (for updates) or if you Save Preferences (then it writes the version). But like you said, it shows the correct version in the driver code window, so you got it.

Child devices do not rename their label to match what the API provides unless their label field is null (blank). That way people can label them something on their Hubitat and it will not be impacted by what they set on their Unifi controller. This is by design. If you do want to "sync" them up you can:

  1. Delete the label and Save the device info. It should change when it next receives the data.
  2. Set the Device Name in the device's Preferences to match what you labeled it and Save (this should attempt to change it on the controller).

Thanks,
yep, I got that from when I had "Cannot get property 'label' on null object " errors.

Still, my child presence device has an empty label and it does not update from the controler even if I save.

The null errors should have gone away, I added a check to make sure the child exists before attempting to check if there is a label for the child.

Save will not update the label... but it should populate when it gets data from the API that includes the device name.

The other side of this is that the Unifi Controller has to have an actual name for the device. For example, I added my Pixel 8 to the Presence checking and it created it, but did not label it. So the label was blank. It should get the Name, correct? If I go into the Unifi controller and check the client devices I can see that it has a name in the list... but it really does not. If I select it I can see this:
Pixel8inUnifi
The name field is blank on the controller and it is providing it some "generated" name. If I enter something into the Name field and Save it will now have one. So I named it Pixel8.

Went back to my Hubitat and by the time I logged in and opened the devices, the child device's label has been switched to Pixel8.
Pixel8inHubitat

Now, if you have entered something into the Unifi side and saved it and it is not showing up... then I have more work to do because I JUST did this to get the screenshots...

First off, again, thanks for the very clear answer and for your great patience.

So, ok, I id not have a name in the unifi controler for my phone as it was displayed by my host name and model number so I was expecting this name to appear in Hubitat, i did not know I had to set this up.

So, I entered a name for it in my Unifi controller and saved, it did not update in Hubitat on the presence child.
it's presence has been checked a few times since and it does not update still.

now, since this child had been created by a prior version of the driver, I deleted it
--> it was re-created with the right label right away

Thank you very much for all of this and for beeing very quick and pro-active.
Have a great evening!

Yeah, some of these systems (like Unifi's) that make things easy with default values are actually making it more difficult behind the scenes. If they show it as a name, why not just POPULATE the name field?!

It should have gotten the label even after a child was created so that is odd... I will look at that more over the week (lower priority than the stuff not working at all).

Thanks again for bringing stuff up! Better to hear about it and get it fixed.

1 Like

"Thanks again for bringing stuff up! Better to hear about it and get it fixed."
no problem, glad i could help testing stuff

Would you think that it would be possible to add a presence value on the child APs (unifinetworkchild-AP) so we could use presence to know when / which AP is up and get alerted ?

Thanks

The AP child driver actually does have the Presence capability and there is field that used to be reported by the API "isConnected" that set the presence for things like the APs, switches, and such. It no longer appears to be provided though (I do not see it on recent samples).

You could check the LastSeen or Uptime events, but they would require parsing to get something more useful. I was trying to do something in Rule Machine to provide you a method... but hit either something I do not understand or a bug, so I posted about that in the Rule Machine area.

ok,
would be a nice to have but what you did already is very impressive.
Thanks a lot

I will keep the AP presence in mind, if I see a field come in that would be useful with the regular checks.

1 Like

I'm having a similar (likely the same) problem on my setup. The last presence update to any of my child devices was Feb 25, though I can see the Unifi parent doing the presence probes in the logs. I'm on 0.4.77, which it looks like should have the fix (and I did an HPM Repair to make sure everything was updated), but I can't seem to get the Presence children active again.

I've tried removing one of them and it isn't being recreated. I'd rather not be too destructive in my troubleshooting, if I can help it. Am I missing something obvious to check?

The logs for the child device are nearly silent -- on a Refresh command, I see this:

The parent meanwhile sees the Refresh and does a check, but doesn't appear to do anything with the result.

Strange... is there any chance that the MAC address reported by the phone has changed? I know on Android phones they will use a randomized MAC to connect to WiFi (and I think iPhone was going/did something similar). I know I had to stop my phone from doing that on my home WiFi so I could accurately monitor it... although then it should show the presence as "not present" even if it was there...

You can remove the second image since it has your network information... I will shoot you a separate message.

Any chance of getting a UCG Ultra driver or does the UCG Max child work?

It would not automatically recognize the UCG Ultra, because I do not have the model information. It should not need a separate driver though, it looks like I could reuse the Max driver I already have.

If you look at the Generic child device it made for it, can you check what the value is for the Model down in the State Variables list? Once I have that I can add the recognition in. I have an update coming soon anyways for other data changes, plus if there is anything I can figure out for @mbishop.

1 Like

I'll work on this this weekend! Need to set up some firewall rules to allow the communication.

1 Like