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. As of version 0.4.0 there is a massive change in the child drivers.
- UnifiNetworkAPI.groovy is REQUIRED
If you want to do presence detection you must also have:
If you want to do hourly client checks you must also have:
If you want to use the Unifi Children feature (where each Unifi device becomes a separate child, enabling more features) then you need drivers for whichever devices you might have (you can load them all if you want):
- UnifiNetworkChild-UDMP.groovy - For Unifi Dream Machine Pro
- UnifiNetworkChild-UDMPSE.groovy - For Unifi Dream Machine Pro SE
- UnifiNetworkChild-UDM.groovy - For Unifi Dream Machine
- UnifiNetworkChild-AP.groovy - For general Access Points
- UnifiNetworkChild-RPS.groovy - For Redundant Power System
- UnifiNetworkChild-Plug.groovy - For Smart Plugs
- UnifiNetworkChild-UHDIW.groovy - For In Wall AP
- UnifiNetworkChild-UP6.groovy - For Power Strips
- UnifiNetworkChild-USPPDUP.groovy - For SmartPower Pro PDU
- UnifiNetworkChild-USF5P.groovy - For Flex 5 Port PoE Switch
- UnifiNetworkChild-USMINI.groovy- For Flex Mini 5 Port Switch (not PoE)
- UnifiNetworkChild.groovy - A "holding place" driver for unidentified devices
- UnifiNetworkChild-BasicAP.groovy - BasicAP driver for APs that lack the status LED ring
- UnifiNetworkChild-USW8 - For 8 port switches without PoE
- UnifiNetworkChild-USW8LPoE - For 8 port "lite" switches with PoE on ports 1-4
- UnifiNetworkChild-USW8PoE60 - For 8 port switches with 60W PoE for ports 5-8
- UnifiNetworkChild-USW8PoE - For 8 port switches with PoE on every port
- UnifiNetworkChild-USW16 - For 16 port switches without PoE
- UnifiNetworkChild-USW16LPoE For 16 port "lite" switches with PoE on half the ports
- UnifiNetworkChild-USW16PoE - For 16 port switches with PoE on every port
- UnifiNetworkChild-USW24 - For 24 port switches without PoE
- UnifiNetworkChild-USW24PoE - For 24 port switches with PoE on every port
- UnifiNetworkChild-USW48 - For 48 port switches without PoE
- UnifiNetworkChild-USW48PoE - For 48 port switches with PoE on every port
- Can create a child device for EACH Unifi Device the controller has, allowing additional features and data to be represented within each by enabling "Show Unifi Devices as Children?" feature on the parent device.
- 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.
- Can perform hourly client checks against up to 20 client devices to determine if they are online/offline as well as various connection-related data for them. Related to the Presence check but it will only check each device once per hour and uses a different child and driver. This is meant more for keeping a general check on important (but not critical) network connected devices.
- 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 (or higher) and is not run via the Unifi controller.
- Unifi devices listed as children can be removed as desired. If the Unifi Children "Show Unifi Devices as Children?" feature is still enabled they will be recreated automatically on the next daily check. If the feature is disabled all of the Unifi device children will be automatically removed (Presence children are not affected).
- 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.
- 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.
REQUIRED: If you use a Controller Type of "Other Unifi Controllers" go back to the Preferences after you save. There should now be a field showing Controller Port # that is required. This defaults to the typical 8443 but newer Controller versions may be using 443.
OPTIONAL: Add any child drivers in using the same method as step 1. Technically they are all optional if you do not use automatic presence detection or the Unifi Children feature.
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!