[RELEASE] UniFi Presence Drivers for Hubitat

[RELEASE] UniFi Presence Drivers for Hubitat – v1.7.4.0 (Stable)


I’m happy to announce the stable release of the UniFi Presence Drivers — a parent/child driver pair for Hubitat that integrates directly with a UniFi Network Controller or UniFi OS Console to provide wireless client presence detection and optional guest monitoring.

There are many like it, but this one is mine. :wink:


:open_book: Background

I have been using @xtreme22886’s UniFi-Presence-Sensor all the way back to the SmartThings times. That has done yeoman’s work all these years, even through the migration to Hubitat. It has been the most reliable and consistent method for presence detection for me.

There were two minor items I wanted to address:

  1. Presence detection was based on polling the UniFi controller via a Python script that ran in a Docker container. While not at all a heavy load, there were the occasional issues that required a container restart.
  2. Polling (every 5 seconds) created an additional load on both the hub and the controller.

I looked for a solution that was event-driven. I didn’t find anything that fit exactly what I wanted, so I created this event-driven, device-driven solution that doesn’t need anything external.

  • This project began as a fork of work originally shared by @tomw — big thanks to Tom for the foundation :raised_hands:. The first things I added were manual Arrived/Departed buttons and the AP Display Name.
  • From there, my goal was to create a lightweight, event-driven driver that listens to UniFi, interprets presence, and surfaces it as standard Hubitat attributes.
  • Along the way, the project expanded to include:
    • Hotspot guest monitoring for UniFi guest portals.
    • Automatic child device creation (wireless clients seen within the last X days).
    • Disconnect debounce handling (avoids false departures when Wi-Fi roams).
    • Sysinfo attributes pulled from UniFi controllers.
    • Resiliency features like proactive cookie refresh, event filtering, and websocket recovery.
  • I know there are other UniFi drivers out there that are more comprehensive, but my goal was to make the most efficient presence monitoring. Those others provide more details into UniFi devices and their control. I just wanted presence monitoring. :wink:
  • Today, v1.7.4.0 marks the first public release: feature-complete, hardened, and ready for everyday use. Paraphrasing Clausewitz: “No driver survives first contact with production.” :sweat_smile:

:sparkles: Features

Parent Driver: UniFi Presence Controller

  • Connects to UniFi Controller / UniFi OS and listens for events.
  • Tracks wireless clients for presence detection.
  • Supports optional Hotspot Child device for guest monitoring.
  • Automatic Child Device Creation: add clients seen in the past X days (default = 1). This was my way of not creating an app to go along with the device drivers in order to select which devices to monitor. It will create child devices which can just be manually deleted if not needed. Be careful though; you probably have more ghost devices in your UniFi controller than you realize.
  • Bulk Management: Refresh or reconnect all children.
  • Summaries:
    • Child Devices → “X of Y Present”
    • Guest Devices → “X of Y Present”
  • Sysinfo Attributes pulled from UniFi: deviceType, hostName, UniFiOS, Network.
  • Resilient cookie refresh.
  • Wireless-only event filtering for performance. (This reduces the load on the hub by not having to parse JSON for LAN events that are not relevant to Wi-Fi monitoring.)
  • Debug and raw event logging (auto-disables after 30 minutes).
  • Scheduled jobs such as debounce timers are canceled across reboots.

Child Driver: UniFi Presence Device

  • Works as a Presence Sensor in Hubitat.
  • Commands: Arrived, Departed (these weren’t part of the original but certainly do help troubleshooting pistons and rules).
  • Attributes (visible in the GUI and available in WebCoRE and RM for monitoring):
    • presence / presenceChanged (timestamp)
    • accessPoint (IP), accessPointName, SSID
    • hotspotGuests, totalHotspotClients
    • hotspotGuestList, hotspotGuestListRaw
  • Automatically syncs name and label with parent.
  • Normalizes MAC formatting.

:zap: Quick Start

  1. Install via Hubitat Package Manager (HPM)

    • Search for unifi or presence.
    • Or install directly using this manifest:
      https://raw.githubusercontent.com/MHedish/Hubitat/main/Drivers/UniFi-Presence-Sensor/packageManifest.json
      
  2. Create a virtual device with the UniFi Presence Controller driver.

  3. Enter your UniFi IP, site name, username, and password.

  4. Save Preferences.

  5. Use Auto Create Clients to add wireless devices, or manually add devices by entering their MAC address.

  6. (Optional) Enable Hotspot Clients to track guest devices.

    • The Guest device will be automatically created.
    • It shows present if there are any hotspot guests connected.
    • It also contains an attribute with the number of guests — something Xtreme22886’s driver didn’t provide.

The README.md is available here.


:memo: Version History

See the full Changelog for details.

9 Likes

Thank you for creating these drivers, they work exactly as expected. Much appreciated!

2 Likes

image

Well done on this (and it's yours). :wink:

2 Likes

You're welcome!

1 Like

How does this work when MFA is enabled on the UniFi account?

Hello, very good work, I also have the same question if MFA is active. Thank you!

This uses a local admin account. You cannot use your Ubiquiti Cloud account with MFA.

You need to create a separate local account on your controller.

  • In your Network Application, go to Admins & Users in the left navigation bar.
  • Select the “+” symbol at the top.
  • Add your admin information.

I created the new local account, no success:


I feel like I missing something, but I don't know what!

Local admin account worked for me. I was seeing the same error in the logs as you. What I ended up doing was

  1. In the UniFi Controller, deleted the local account I made
  2. Create a new local admin account
  3. Log into UniFi controller with the account to make sure the credentials work
  4. Go the UniFi Controller device in HE and update the credential

I found that I did could set the username in UniFi to whatever I want (for example, "hubitat"), and that username goes into the username field in the Preferences tab in HE. It doesn't seem like I needed to match the local admin's username password to the UniFi owner account.

Correct, those are precisely the troubleshooting steps I'd take. :wink:

The local admin account is completely separate from your regular account and can be named anything you want.

@userLP24. Are you able to login with the credentials you created manually? Also, double-check the details on the preferences tab.

What did you enter for the site name setting? I entered the name of my device (which contains a space) and I got all sorts of errors, including the ones shown in your screenshot.

I didn't read closely enough, but when I changed the site name to "default" everything started working.

@MHedish You probably should remove the required flag for site name and just default to "default" if it's blank. Also, you should url encode whatever is in site name or else it throws another error, like this:

httpExecWithAuthCheck() general error: Illegal character in path at index 49: https://10.0.7.1:443/proxy/network/api/s/Wildwood House/stat/sysinfo

I'll put the URL encoding on the revision list. That'll cover the issue with the space in your device name.

Good evening! Following these excellent instructions above:
In the UniFi Controller, I deleted the existing local account, created a new local admin account, logged into the UniFi Controller with the new account to verify the credentials worked (and they did!), then went to the UniFi Controller device in Home Assistant and updated the credentials.
A few minutes later, it worked! Thank you very mutch!

[UPDATE] UniFi Presence Drivers for Hubitat – v1.7.5.1

A quick maintenance update for the UniFi Presence Drivers (Parent/Child pair).
This patch addresses missing WebSocket handlers that could cause error logs during event stream operations.


:hammer_and_wrench: Changes in v1.7.5.1 (2025-09-17)

  • Parent Driver
    • Added missing webSocketStatus and webSocketMessage handlers.
      Prevents MissingMethodException errors when Hubitat receives WebSocket events.
  • Child Driver
    • No functional changes; aligned version with parent.

:package: Installation / Update

  • If you’re using Hubitat Package Manager (HPM), simply run Update.
  • Manual installs: update both parent and child drivers via their Import URL.

:open_book: Notes

This is a patch release following v1.7.5.0.
No new features — only stabilizing WebSocket event handling.

As always, feedback and reports are welcome!

@MHedish

I enabled the feature to monitor guest hotspot monitoring. Tried connecting to my guest WiFi but my device is not being picked up by the driver. It does show as connected in my Unifi controller. Is there a specific configuration for the hotspot zone that needs to be set for this to work?

Not at all. As long as hotspot monitoring is enabled, the driver checks for the number of devices currently connected as well as the number of guests that are unexpired but not connected.

In my case, "Guest" is the rollup childDevice and guestDevices enumerates the count.

image

Turn on debug logging and let me know if you see any errors.

I'm using an order Application that looks similar to this. Look for the difference between the two. I'm using Unifi WiFi Presence, Mike10. It's been working OK.. I have this on a separate hub from the main one. Check if Mhedish's application is better—less memory or CPU. I wasn't able to authenticate, and I will need to work on this some more.

I can't get it working. I have tried several different login credentials with no luck.

1 Like

I don't see any errors with debug logging enabled, however, devices connected to my guest network are not populating at all.