Unifi detected presence stuck at away when meshed AP briefly lost connection

I have two Unifi APs: One in the living room connected via Ethernet to my router, homeassistant, etc. and a second AP in the entrance hall that uses the wireless uplink to the living room AP. At night my phone is associated to the entrance hall AP.

Now I have my presence detection set up to use the Unifi network integration. This works pretty flawlessly most of the time, but at night (around 3 am) it seems like the entrance hall AP loses connection for about 30 minutes (I see this with the device_tracker and I also see a gap for my phone during that time in the Unifi controller). After that my presence remains stuck in “away” even when the AP is detected back again, it only comes back when I move to the living room and the mobile phone associates to the other AP. What I find strange is that while the device tracker marks the phone as away, it does reappear in e.g. the TX and RX statistics that (I think) come from the Unifi Network integration too…

Is this expected? I’d like to keep using the Unifi integration for presence detection if possible, so any ideas on how to work around this would be appreciated.

If it’s useful I can add screenshots of the graphs (though the forum only lets me add one per post at the moment). I’ve added the debug option for the unifi integration and will update the post after this happens again (likely tomorrow).

Hi !
Are you sure that your phone does not go to deepsleep then cuts WiFi off ? My phone do this during the night and I can clearly see it on the device tracker. Using also Unifi AP (no wireless uplink as I have only 1 AP).

image
Do NOT judge me on my mouse writing skills lol

Several thoughts:

What are you using to control the APs? eg DMP, UDM, DMSE, HA add-on, etc?

Why are both APs not wired? I realize it’s much more convenient to do things the way you have them, but the reality is that it’s FAR from optimal. It adds additional technical complexity, degrades performance, and can cause many other issues (such as roaming) as well.

As for the TX/RX values - I think they can also be gotten via the companion app. Take a look at the entity in HA and see what it’s called, then compare that against your list of entities from the Ubiquiti integration.

1 Like

Hello!

There has been some rework of how client tracker calculates presence (UniFi events aren't reliable for device tracker usage, use last_seen instead by Kane610 · Pull Request #64147 · home-assistant/core · GitHub), please try it out with the 2022.2 beta released today.

If that does not improve things you can start looking at the logs and maybe evaluate if there is some way to improve calculations when deep sleeping if for example this attribute can be used powersave_enabled (aiounifi/clients.py at a1bf31813e2bb2f9d20d35c4c2d3fc3cd067bbbf · Kane610/aiounifi · GitHub)

1 Like

@Robban - so this commit is in today’s dev release?

I have an automation reload the Unifi integration when all known phones are ‘away’ yet the alarm is disarmed.

I had problems up to yesterdays dev release.

Hopefully this removes the need for this :slight_smile:

1 Like

It was merged 2 days ago so that would be correct

Oof, went from Jan 25 dev to 26.04 dev and Unifi is completely borked. No device_trackers at all. Gulp. Will submit issue.

1 Like

Hi,

Ok, thanks for the replies and the information regarding the new version regarding the client tracker. I can indeed report that I didn’t have the issue this morning, but of course it’s a bit early to tell if it’s indeed fixed or just coincidence.

Thanks again!

After a few days presence detection still works flawlessly, so I think it’s safe to assume that the fix by @Robban did the trick. Thanks!

1 Like

Sweet! Thanks for helping verifying the change!