Unifi Integration Devices Never Leave Home

Hi All,

Anyone else noticing that their Unifi Controller presence detection integration isn’t marking devices as away when they disconnect from wifi?

I can force the state to away, and it will stay that way until the device reconnects to wifi. Upon re-connection, the device is shown as home, as it should be. However, when it disconnects again, the integration never shows it as going away. So, the integration is talking to the controller at least sometimes. I’ve tried setting the time to be considered away to 30 seconds, and that doesn’t seem to make a difference.

The device disappears from the Unifi controller device list, so it seems like the controller knows it’s gone. The controller is running on a separate pi.

I’ve reinstalled the integration, deleted the unifi_data file, rebooted HA numerous times, and tried different devices and it always behaves the same.

I installed .106 today, as well as switching from SSL in Homeassistant to SSL via Nginx proxy, so its possible that one of those changes broke something in my instance, although I saw that there were some changes to Unifi in .106 and .106.1, so could be a code issue too.

Before I report a bug, has anyone else had issues like this recently? (or have ideas on how to fix it?)
Prior to today it worked perfectly.

Thanks!

I have the same issue with the unifi integration.

Ye I’ve noticed it. A restart of HA fixes it temporarily.

For me, once home a device never leaves, unless I reboot or force a state change, so the reboot really just resets the state it seems.

1 Like

There is a bug raised already

It was found and raised the day before the release of 0.106

What I personally do not understand it why 106 was released with this bug. A device tracker integration that cannot track if a device changes state from home to not home is not very useful. You have to restart home assistant to get the states updated. I cannot imagine that anyone can use the Unifi integration for anything at the moment.

Can we get it reverted back to what it was in 0.106.2 while the dev works on getting it fixed?

Geez and I thought I searched every word combination to see if this was already identified before I posted…

The issue was reported the day before release and I haven’t had time to look into it, according to my tests writing the changes it all worked. I have a hypothesis about how to solve it, but I need some logs to verify this to not create multiple fixes that are not founded on proper data.

It is also hard to revert changes

How long do you need logs for? I had logging enabled but my log file was 35mb overnight since the integration updates every few seconds across all the devices on my WLAN, so I erased it.

Also what about state? Should I restart HA with devices off/set state to away, catch a few cycles, then connect the devices, then disconnect them again?

I don’t think logging for restart is necessary. Since that is a known behavior. Mostly I just need logs. Preferably with as few unrelated items as possible. If you put default logs to error and only share the debug output for unifi integration and aiounifi would be a good start. I just want to see what is actually sent over the websocket

I just put some logs on the bug report. I assume you just need two example of the periodic logs entries.

I posted one where my IPhone was on the wifi. And then I turns wifi off on the phone and captured the log entries that followed.

And I also verified that HA does not see the phone as away as it should

Great! Thanks

I do not want to pollute the github with silly questions so I will ask here

How do you guys try the short term fix? Do you all run venv or do you copy the whole unifi code as custom component? Or is there a way to edit the files inside the docker container so it survives a restart?

I think part of the problem is the means by which the ‘Person’ integration decide if you are home is fixed and cannot be adjusted. I’d like to be able to control how that decision is made and decide for myself which side to err on.

I also not there is a significant change in the unifi code for 0.106 so there is a very good chance of a bug being introduced.

Temporal fix on 0.106.2:
Unifi temp fix

You can edit files and restart hass without restarting the container I think

I just copied all the Unifi files into config/custom_components/Unifi and restarted ha.

Note that you need (I think) at minimum manifest.json and init.py as well as the modified files. I copied all the unify component files over as that seemed easier.

You’ll get a log entry saying you’re using an unsanctioned version of the unify integration once it’s found it and is using the new files, so then you’ll know its working.

Still not fixed with 106.2, my devices won’t come “home” now. Already removed and readded the integration, but unfortunately doesn’t solve the issue.

Worked fine for months…

Try upgrading your controller

I’m running version 5.12.35 which is the latest stable?

Devices’ home/away status still not being updated for me on 0.106.2