Unifi AP's as presence detection for automation


If you have random macs switched on it keeps discovering it as a different entity. i.e. tablet_1, tablet_2 , tablet_3 etc.

I think you are right. At my WiFi settings I disabled “Private Wi-Fi Address”. When I lookup my iPhone I only see the ‘Mobile App’ integration. Not the Unifi Network integration.

Try reloading the unifi integration to see if it finds the device_tracker after changing the private address setting

Already did, no-go.

I think I will need to place this on pause and pick up something else to improve with HA :-).

@ Dschiii Thank you for posting your sample automation, it helped me resolve a very similar scenario. I simply want an action to be executed when I enter into the area of one specific WAP, and I can accomplish that with this very simple automation. That is indeed, provided the Unifi device tracker for my iPhone is enabled, because that is a different tracker than the default Apple iOS tracker, and it’s disabled in the Unifi integration by default, thus very important to go enable it.

I also learned you can use a wildcard concept between multiple WAP, simply by leaving the “from” field blank (e.g. when disconnecting from any WAP and connecting to a specific WAP), handy!

Thanks everybody, got this working now.

Purely based on my experience to get this one working, took a while because some details are available in the thread but hard to interpret.

So a little summary for quick references.


  1. Disable on your iPhone the private wifi adress in your wifi settings, mandatory
  2. Make sure you follow the instructions to add the Unifi AP device tracker in HA
  3. Make sure you got the Unifi Network integration installed, otherwise ap_mac adress wont be available, mandatory
  4. Use in your automations the device tracker of the unifi network integration
  5. When using the ap_mac transition in your automation, make sure it is all lower case
  6. If you want, like me, to use it when you come home and connect to your wifi network leave the from adress in the automation empty.

Thats it!

In most cases you don’t need to disable it - what this feature means is a private MAC address per network, but as long as you’re connecting to the same network, and not taking 6 weeks in between, you’ll get the same address:
Use private Wi-Fi addresses on iPhone, iPad, iPod touch, and Apple Watch - Apple Support.

Thanks for the contributing, I needed to turn it off on my iPhone otherwise the tracking and its integrations didnt work.

I changed the point in the summary, that it is not mandatory.

Quick question:

Did you have Unifi Network Integration installed before or after Unifi AP device trackers manual config? I see almost all my IoT devices but not my iPhone / laptop in the list of ‘devices’.

I installed it after I added the Unifi AP Device tracker.

reason for that was that I didnt see the AP_MAC attributes at the known tracked entities. The moment I added the network integration and let HA talk to my Dreammachine the correct device tracker showed up and could be use.

Really happy with this setup now!

1 Like

Update: I finally got my private devices now listed as well.

For some reason; when I install the UniFi Network integration it only gave a couple of devices and the WLAN’s. After, I went to the integration and hit the ‘Configure’ button. There are multiple steps:

  1. I skipped the first one (UniFi Network Entity Sources) by pressing next.
  2. Now the 'Unifi Network options /13 will be shown. Now I was able to check my SSID’s to track wireless clients on which did the trick.
  3. After you’ll go to UniFi Network options 2/3 I also skipped but kept the ‘Allow control of DPI restriction groups’ checked.
  4. In the last step I checked the Bandwidth usage sensors for network clients and pressed submit.

Now I got a lot more devices as it should have. When I go to Developer Tools > States > Filter on attributes with the value ‘ap_mac’ I get my private devices as well. Now I can start automating stuff with detecting my devices.

So, I’ve been digging into this issue again. And I have some foundings I don’t understand.

Just to be clear: I added the AP_direct and later on the unifi integration (official one of Unifi).

When I go to Developer tools > States > Filter on attributes with ‘ap_mac’ I only see devices that are on my IoT WiFi network. When I switch with my iPhone to the IoT network, I see at devices the correct WiFi but I don’t get a ap_mac for this device. How is this possible? And why is only my IoT network as essid available and not my other network? Ps; My other network is found by the unifi integration.

Hi everyone.

I’ve got about 7 Unifi APs throughout my house and want to use them for presence detection of smart phones.
I’ve gone through this thread and did everything as described and got the integration working. I can see the ap_mac attribute for my phone entity, etc.

My issue is that it seems to be super unreliable. Sometimes the unifi network integration will immediately update HA that my phone has gone offline, for instance. Other times not at all.

I have a remotely hosted unifi console and the unifi app so I can see my phone when it’s on the wifi and I can see which AP it’s connected to etc.
In one test I tried turning my phone wifi on in my office (office AP) and waiting till I could see the phone connected to that AP in the unifi console. HA just did nothing though.
After like 20 mins HA registered my phone as online but the ap_mac was for a different AP (big lounge) on the other side of the house and to which the phone was definitely not connected, but had been previously before this test.

I’ve tried reinstalling the addon and had some help from a buddy who’s an HA expert and software dev and his phone’s presence was also spotty.

Has anyone had this kind of experience with this integration and is there a fix or workaround to get unifi to push info more often or something?