This is a parent/child set of drivers in order to read data from your Unifi controller (originally based around my Unifi Dream Machine Pro but now expanded to other Unifi controllers) and provide some information that may be useful to your Hubitat. Like most of my drivers this will be a perpetual project and I am always open to feedback.
On to the good stuff, the drivers. You will need both if you want to use the ability to regularly check for network presence (check for active MAC address on network).
UnifiNetworkAPI.groovy & UnifiNetworkChild.groovy
- Can show all the active (non-archived) alarms present for the controller as well as Archive the alarms.
- Can manually check for whether a MAC address exists in the controller's database and will produce an Event stating the result.
- Can manually check for whether a MAC address is currently online and will produce an Event stating the result.
- Can manually check the current status of the controller and will post events showing the "health" of the major areas (for example: wlan, www, wan, vpn, lan).
- Can manually Refresh the overall status of the controller. Showing data such as how many clients have ever connected and how many are currently online as well as how many Unifi devices are connected to the controller.
- Can be set to regularly perform a Refresh and get other general stat information for the controller.
- Can be set to regularly poll whether particular MAC addresses are online. This can be used as a form of presence sensor as these will create child devices that will label as present (or not) if online (or not). Example: My smartphone is checked. If it is on the network then it must be home (and therefore I should be as well). Currently it is fixed that if you have <= 5 MACs being checked it will check all 5 each minute (spread across the minute to not cause excessive load). If you have <= 10 MAC addresses it will be performed every other minute. >10 MAC addresses is not currently allowed.
- At a fixed interval (1 hour) it will perform a login to the controller in order to keep the authentication cookie accurate.
- Can perform a Hubitat-based Ping command against a specific IP. This requires Hubitat version 2.2.7 and is not run via the Unifi controller.
- Now listed within Hubitat Package Manager (HPM).
Major Feature(s) Missing:
- None known at this time, it is performing all expected/desired functions until there are some requests.
- Add UnifiNetworkAPI.groovy driver to your Drivers Code section on your Hubitat (you can Import using the URLs above) then Save the driver. Repeat with the UnifiNetworkChild.groovy driver.
- Add a Virtual device and set the Type to be UnifiNetworkAPI (user-added drivers are going to be at the bottom of the list), then Save Device.
- Enter your Unifi Controller's IP/Hostname, Username, and Password into their respective fields in Preferences, select your Unifi controller type, then Save Preferences.
OPTIONAL: If you use a site different than the default (most people see "Default") then enter the site in the Override Default Site field.
Enjoy checking out the features!