Unifi Device Tracker thinks phone keeps going off the network

Every 6 months I try to incorporate device tracking in my HA system, I try for a month, get fed up and stop again for another six months.

I am attempting to use the Unifi integration again. It thinks my phone (and my wife’s phone) are constantly getting on+off the netwrok. My iPhone has been sitting on my desk all day and when I look at the history its on/off/on/off for the past few hours.

I do have my “time in seconds to be considered away” set to 30 seconds… which i realise is lower than the default of 300, but the few youtube videos I watched had theirs set to 30 or 10.
But in theory, it shouldn’t even be reaching 1 second as it’s not falling off the network.

Any ideas on how to make this usable? (I don’t really want to keep upping the seconds-aways value, as that defeats the purpose of telling me when the user has left the zone), and 5 mins after the fact isn’t helpful.

The phones are NOT set to randomize their mac address on the network.
And checking the uptime for my phone inside my Unifi console and its: 15h 12m 51s

Am I missing something here?



Screen Shot 2022-09-15 at 2.13.39 pm
Screen Shot 2022-09-15 at 2.13.48 pm

Doesn’t the companion app have stable entities for WiFi?
On Android they are very stable.

With the companion app, won’t I need to use the paid Nabu Casa service? or at least have a VPN to my home network running on my phone?
Otherwise it wouldn’t be able to inform HA that I am now no longer on the network? or ?

True. You need some path in to your network

You phone might be just idling on the desk, but the power saver settings can and often are set to deactivate WiFi, and idling means you are not using it, so no priority is needed.

1 Like

That’s a good theory but I wonder why the Unifi console shows the correct uptime (15h 12m 51s).

If the unifi console says I never dropped off, why would the integration?

I have the same problem with a door lock.

I think you’ll know when the door leaves the zone :wink:

Joking aside, I wonder why these devices are reporting that they have fallen off the network.

1 Like

I have an iPhone and 2 Android in the family, and using nmap integration for device tracker, and I know nmap is tracking via arp. What I learned from this setup is that, for Android, things are fairly consistent, but for iPhones, night and day. iOS has some anti-tracking and power conservation mechanism built-in you cannot get around, it seems.

So, if the device tracker feature under unifi integration uses arp also, you probably could see the same thing on your iPhone.

One way to test the theory is to setup the nmap integration and configure it to track the IP of an iPhone… see if the plots would more of less line up with plots from unifi integration on the same device.

The device tracker feature for Unifi actually gets the data directly from the controller of what devices are actually connected to the access points at that moment in time. If the iPhones aren’t connected at that moment then they will be reported as away, once the last connected timestamp is at least the configured threshold (30 seconds for OP) ago. There is a good chance that the iPhone only checks in once a minute. As long as the device is still regularly checking in - Unifi won’t record it as offline. I don’t know what the time period is that Unifi waits before declaring a device is offline though. I also don’t know if the iPhone uses any of the battery saving extensions to WiFi that allows the radio to go to sleep. At a guess though - I’d assume that the iPhone is probably using the battery saving feature - so the radio can go to sleep and wake up periodically to check if there are any messages for it, as long as the radio continues to connect during the scheduled window - then Unifi will consider the device to be online, even though for a period of time it’s not really.

EDIT:

The UniFi Network Application has a 60-second disconnection threshold, meaning that it will wait one minute for a response from the device before declaring it disconnected.

From a quick Google search

Try increasing the timeout. Unifi reporting is finicky so having it too low will cause this erratic behavior

Ok, this is good to know! I am going to set mine my ‘considered-away’ threshold to 120 seconds and see how much of an improvement that makes for the next few days.

thanks!

2 Likes

Unfortunately, with the time set to 2mins, its still going on/off over night. This is from 9pm to 9am…

You need to look at the phone settings.
The UniFi device just report the phone behaviour and the HA just report the UniFi device behaviour.

If you can not change the phone settings, then you need to increase the time to fit the phone settings.
The settings in the UniFi device is of minor importance.

Do you have any suggestions on what settings to look at? (It’s an iphone)

I have no idea for iPhones and you might actually not be able to change those settings at all, because Apple thinks it’s users are incompetent.

Their uses has not requested that feature

Hi @AstroBBoy! Any progress on the Unify integration behavior?
I’m facing the exact same issue here…

Unfortunately not. I gave up to be honest.

@andrepia I finally found a way to enable tracking for my home.

As I have AppleTV, I use homekit to do it for me:
https://jonas.brusman.se/homekit-presence-home-assistant/

It’s been flawless and I haven’t noticed any battery drain.

I know a lot of people have been able to use the HA app, or Unifi tracker etc, but they wouldn’t play nicely for me. This does the trick.