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 information that may be useful to your Hubitat as well as some level of control over the devices. 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 themselves.
- 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.groovy - A "holding place" driver for unidentified devices. Not required but can be handy to get information for new devices.
- 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-UDR.groovy - For Unifi Dream Router
- UnifiNetworkChild-USG - For Security Gateway
- UnifiNetworkChild-UGW3.groovy - For Security Gateway 3
- UnifiNetworkChild-UGW4.groovy - For Security Gateway Pro (USG-Pro-4)
- UnifiNetworkChild-UX - For Unifi Express Gateway
- UnifiNetworkChild-UXG - For Unifi Gateway Lite
- UnifiNetworkChild.groovy - A "holding place" driver for unidentified devices
- UnifiNetworkChild-AP.groovy - For general Access Points
- UnifiNetworkChild-RPS.groovy - For Redundant Power System
- UnifiNetworkChild-Plug.groovy - For Smart Plugs
- UnifiNetworkChild-ACIW.groovy - For AC In Wall AP
- UnifiNetworkChild-UHDIW.groovy - For U6 In Wall APs
- 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-BasicAP.groovy - BasicAP driver for APs that lack the status LED ring
- UnifiNetworkChild-US8 - For 8 port switches
- 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
- UnifiNetworkChild-USAGGPRO - For Aggregation Pro switches
- UnifiNetworkChild-USPM16P - For Pro Max 16 port switches with PoE
- UnifiNetworkChild-USPM24P - For Pro Max 24 port switches with PoE
- UnifiNetworkChild-USPM48P - For Pro Max 48 port switches with PoE
- UnifiNetworkChild-USPM16 - For Pro Max 16 port switches without PoE
- UnifiNetworkChild-USPM24 - For Pro Max 24 port switches without PoE
- UnifiNetworkChild-USPM48 - For Pro Max 48 port switches without PoE
Features:
- 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).
- Can control Port PoE states, set Etherlighting on ports, and other switch-specific commands...
- All are listed within Hubitat Package Manager (HPM).
Major Feature(s) Missing:
- Changing network profiles or such are not planned to be incorporated. These require IDs that are contained in the API and are a long alphanumeric string (not the easy to use name) and thus cannot be readily presented to a user to select from in a reasonable way (like the web interface provides).
Setup:
- 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.
REQUIRED: This driver is designed for use with a local admin account. It does not work with Ubiquiti cloud or 2FA accounts. Just create a separate local account on your controller.
OPTIONAL: Add any child drivers in using the same method as step 1. Technically they are all optional if you do not use presence detection, client check, 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.
Extra:
- I am always willing to add more device support or features. If you have a Ubiquiti Unifi device that does not already have a child driver above, please reach out! The minimum I need is the Model (not what Ubiquiti provides, but what is used by the API) which can be found in the child device's State Variables list. You should be able to use the generic "UnifiNetworkChild.groovy" driver for any unknown device just for the basics. Having the Model will let me identify the device in the API data and at least create a new child driver and send the data to it.
- If a child device is lacking some major feature you want and you can do with the Network API on your local Unifi Controller, let me know. If you are willing to help provide some samples I can usually work out a way to add it.
Enjoy checking out the features!