Unifi Presence plugin

This is a plugin that detects presence of network devices based on their status pulled from a Unifi Controller. It is based on the Unifi Sensor plugin by @BlueSmurf. It also borrows from @rigpapa’s VirtualSensor plugin. Thank you both for inspiration.

The plugin consist of one main device per Unifi controller/site. The main device handles authentications and polling. The presence detection is done via virtual motion sensors, which are created through the main device UI. With each poll, the plugin checks the status of a device based on its MAC address. If a device is found to be connected during a poll, its sensor is tripped.

Devices timeout value specifies minimum time for which the device has to be off line before the sensor un-trips. It defaults to 300 seconds. This was necessary to detect devices that would in power saving mode turn off their wifi and only check in periodically. Otherwise, if these check ins happened between the polls the device would be considered not present. For example my iPhone, when on low battery (<20%) and NOT switched to power saving mode, will disappear from the network for several minutes.


download following files from https://github.com/imro2/unifi-presence and upload them to your Vera via Apps -> Develop apps -> Luup files.

  • D_UnifiPresence.json
  • D_UnifiPresence.xml
  • I_UnifiPresence.xml
  • S_UnifiPresence.xml
  • J_UnifiPresence.js
  • L_UnifiPresence.lua

After upload, go to Apps -> Develop apps -> Create device, fill in following values and click create.

  • Upnp Device Filename: D_UnifiPresence.xml
  • Upnp Implementation Filename: I_UnifiPresence.xml

You’ll need to reload the Luup Engine and refresh your browser before the device will appear in the UI.


Create a separate local user on your Unifi Controller for Vera to use, do not use your main Admin account. I had problems creating a user, in the new UI, without a confirmation email being sent. However temporarily switching to the old Unifi UI let me do it.

In the UI for the device, go into the Settings tab and provide the information needed - it should be self-explanatory.

After that go to Virtual Sensors tab and add new child devices using the Create Virtual Sensor button. When you click the button, wait until the new device appears in the list above. Once there, fill in the MAC and possibly rename the device by clicking on its name. Wait a minute for first poll to occur, after which you should see a time stamp under Last Update.

The parent device icon will show Green if you have at least one virtual sensor with a MAC address configured and the sensor was able to successfully authenticate with the controller.

1 Like

Can the local user be read only?

Yes, that is how mine is set up. The plug-in makes no attempts at making changes to the UniFi controller so there is no need for anything more than read only.

This seems to be working pretty good. Thanks for your efforts.

Have you considered propagating more of the device properties to the virtual device, allowing them to be used with things like Reactor, or even just basic scene triggers?

I don’t think that should be a problem. Do you have specific properties in mind?

I hadn’t dug in and looked at them closely. Just scanning the JSON return, I find several interesting:

name (not horribly useful for automation, but could be a nice status indicator)

Some of those have near-duplicates, I’m not sure how the behavior changes between them, but a lot of the timestamps look like they could be useful.

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules