Closed townsmcp closed 2 years ago
Hey there @kane610, mind taking a look at this issue as it has been labeled with an integration (unifi
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
unifi documentation unifi source (message by IssueLinks)
Github wont let me upload the log file (cut down version with sections that I beleive are relevant is just shy of 30mb). Just to reiterate, this same behaviour is seen on all devices that leave wifi (status changes) and then come back to wifi - no change of status on the return until a reload of integration or reboot of HA
@Kane610 any update with this please?
I have updated Unifi Network app today (now on 6.4.53) and the issue is still present, the following is from today (only showing as Home as I reloaded the integration):
Sorry no, there is no obvious reason for this to stop working. Im considering that UniFi is not interested in use cases of really long lived websocket sessions or they are not interested in keeping the events. One possible remedy as one user has done is to create an automation that restarts the integration every 24 hours, a possible fix in the integration is to restart the websocket connection every 24 hours or so, but its hard to decide if thats a proper solution or if I should data mine more places instead.
@Kane610 ah ok, I didn’t realise that’s how it works. will have a look into the integration restart but I think it would need to be every few hours, not 24 hours (integration works for about half an hour after restart and then stops working for devices coming home). I guess the harder solution is to mine for more data from other places.
I have actually opened a support ticket with Unifi for the problem also and the Uptime for all devices is incorrect - the counter keeps increment even when a device is unplugged/ away from home which is certainly not right
I didn't realize you had such a short time before the issue happens, the main problem has been that it reportedly takes a few days to reproduce and my main dev environment is my primary laptop so it is never online long enough to debug three day issues. I will try it again within the next few days.
Its great that you reported it to UniFi, unfortunately they haven't shown any interest in supporting the integration so far the few times I've tried to contact them.
Have you tried looking to make sure that it is not related to any time server configuration?
@Kane610 i have tried looking into time server but to be honest I’m not sure if I have gone down a rabbit hole. The HA integration page says to ensure time is synced on Unifi device and the virtual install of HA but I can’t find anywhere what to do. So I setup a VM with a Chrony in it, pointed the Proxmox host to use the Chrony VM and pointed NTP in Unifi dhcp settings to Chrony VM ip. Also made sure that the region was set correctly on Unifi device and Proxmox host. When I ssh onto Unifi device and type time as the command, and check the LXC container time they both appear to be in sync, or very close to same time (allowing a couple of seconds to switch devices and type in the command). Is there anything else I should be doing for time sync? One thing I have been trying to avoid is resetting udm pro to defaults and restoring settings from backup - I just don’t feel that will resolve the issues
@Kane610 i have tried looking into time server but to be honest I’m not sure if I have gone down a rabbit hole. The HA integration page says to ensure time is synced on Unifi device and the virtual install of HA but I can’t find anywhere what to do. So I setup a VM with a Chrony in it, pointed the Proxmox host to use the Chrony VM and pointed NTP in Unifi dhcp settings to Chrony VM ip. Also made sure that the region was set correctly on Unifi device and Proxmox host. When I ssh onto Unifi device and type time as the command, and check the LXC container time they both appear to be in sync, or very close to same time (allowing a couple of seconds to switch devices and type in the command). Is there anything else I should be doing for time sync? One thing I have been trying to avoid is resetting udm pro to defaults and restoring settings from backup - I just don’t feel that will resolve the issues
You should make sure the controller has ntp server configured, by default it doesnt. That at least affects other devices on network from retrieving ntp over dhcp from the controller. This doesnt necessarily mean it will affect Unifi <-> hass time in any way.
I've started a dev instance with unifi integration to see what happens after 30 minutes. I'm also running UDM Pro on UniFiOS v1.10.0 and Controller v6.2.26
@Kane610 thanks, I have NTP point back to the Chrony VM IP in Unifi OS in System - Application Configuration - NTP, also in DHCP settings.
If I can help in anyway for testing etc etc please let me know - more than happy to lend a hand where possible
It's been running for 1.5 hours so far and no issue connecting and disconnecting my iPhone from wifi and have it reflected properly in device tracker
Hmmm interesting. Might have to factory reset after all and do a restore of settings
I'm not saying that's the difference but it would be an interesting experiment. My dev test environment is on a MacBook so I don't know if that could affect the behavior. I don't think so but I can't rule that out atm
Still working 3 hours on
Still working 5 hours on, I'll be stopping the experiment for now.
@Kane610 so I blasted UDM Pro today by doing a restore to factory defaults and then loaded the settings backup. Still the same behaviour :( The OS and Network app stayed at the same version (I thought it was supposed to restore that back to factory defaults to but it didnt). So the next plan is to do a factory restore again tomorrow, but go into Recovery Mode and downgrade the OS to v1.10.0 and network controlle to v6.2.26. I have made a note of all my settings and devices I have set static IP for and will manually add everything back again rather than a restore of settings.
@Kane610 I also discovered the following repo: https://github.com/Art-of-WiFi/UniFi-API-browser I wonder if that API is pulling uptime and device details etc from the same source as your code?
Since its PHP its probably only polling
@Kane610 well rolling back the firmware and Network controller version has fixed the issue. I reconfigured UDM Pro by hand rather than uploading a backup so as to rule out issues from a restore and everything is working as expected. I did however notice they have rolled the firmware on and network controller to a newer release so I guess this is going to cause problems with anyone who upgrades to latest prod code
There are other issues (https://github.com/home-assistant/core/issues/51709) reported as well, lets keep this issue open until the end of the week to deem it stable.
@townsmcp have you experienced any further issues after resetting your UDMP? Or are we ready to consider this "solved"?
@Kane610 ive experienced no issues at all since resetting back to older firmware and 6.2.26 Network controller. Im tempted to roll up to the latest official release to see if it all breaks again (and if it does I can roll back). Are you still running 6.2.26 as well?
Yes Im running UniFi OS v1.10.0 and Controller v6.2.26
The problem
My Unifi integration in HA is showing incorrect home and not_home statuses for some devices. When the integration is reloaded, it works for approx 15 minutes - devices joining and leaving wifi change status. However after that 15 minute period, a device can go away at any point, which is reflected as not home but wont change status back to home when wifi is reconnected - the only way round it is to reboot HA or reload the integration.
My setup:
I have also built another brand new LXC with HA Container on on a different ProxMox node. Basic setup, no addiotnal devices, added the Unifi controller and observe the same behaviour on that instance of HA to.
On the HA Unifi Integration page I saw a comment regarding time syncronisation between HA (running on a VM) and Unifi device. I have therefore setup a VM with just Chrony running, set the host of the HA LXC to use Chrony for NTP, ensured timezone is set correctly and also done the same in DHCP/NTP on Unifi Network appliance. when running 'time' from SSH CLI on LXC and Unifi, times both appear to be in sync.
What is version of Home Assistant Core has the issue?
2021.9.1
What was the last working version of Home Assistant Core?
Cant remember which version - approx 3 months ago
What type of installation are you running?
Home Assistant Supervised
Integration causing the issue
Ubiquiti UniFi
Link to integration documentation on our website
https://www.home-assistant.io/integrations/unifi/
Example YAML snippet
Anything in the logs that might be useful for us?