core icon indicating copy to clipboard operation
core copied to clipboard

Unifi integration shows device_tracker status for wi-fi devices incorrectly

Open Spirituss opened this issue 1 year ago • 20 comments

The problem

Wi-fi esp device added as "tracked" in Unifi integration. It is permanently online, Unifi controller web site shows it as online device, but HA integration shows "offline" all the time. The same situation is for many devices.

Снимок экрана 2023-11-27 в 10 03 18

What version of Home Assistant Core has the issue?

core-2023.11.3

What was the last working version of Home Assistant Core?

Unknown

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Unifi

Link to integration documentation on our website

https://www.home-assistant.io/integrations/unifi/

Diagnostics information

I find HA devices in Unifi API info ($ip/api/s/default/stat/device/) and see the following client attributes, which have correct (updated) values, while HA shows "not home" all the time:

  • first_seen
  • last_seen
  • _last_seen_by_uap
  • satisfaction
  • satisfaction_now
  • _last_seen_by_ugw

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Spirituss avatar Nov 27 '23 07:11 Spirituss

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!

Code owner commands

Code owners of unifi can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign unifi Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


unifi documentation unifi source (message by IssueLinks)

home-assistant[bot] avatar Nov 27 '23 07:11 home-assistant[bot]

Please share a debug log

Kane610 avatar Dec 04 '23 21:12 Kane610

Please share a debug log

Here config_entry-unifi-redacted.json.txt

Spirituss avatar Dec 05 '23 07:12 Spirituss

What version of unifi are you running

Kane610 avatar Dec 05 '23 19:12 Kane610

What version of unifi are you running

HA official Add-on, the last available version: UniFi Network Application Current version: 3.0.0

Spirituss avatar Dec 06 '23 08:12 Spirituss

That's the addon version not the software version

Kane610 avatar Dec 06 '23 09:12 Kane610

That's the addon version not the software version

Network 8.0.7

Spirituss avatar Dec 06 '23 10:12 Spirituss

Can you enable debug logging for the integration and share the logs?

Kane610 avatar Dec 07 '23 21:12 Kane610

Having the same issue.

HA Core 2023.12.2 Unifi Network Network 8.0.24

States in Unifi Network do show correct.

[Solved for me] Edit: The logs showed my user couldnt login anymore. Maybe because of new Unifi OS password length requirements. Changed the password to a longer (12+) length and updated the integration. Now it works again.

a-r-j-a-n avatar Dec 14 '23 14:12 a-r-j-a-n

Having the same issue.

HA Core 2023.12.2 Unifi Network Network 8.0.24

States in Unifi Network do show correct.

[Solved for me] Edit: The logs showed my user couldnt login anymore. Maybe because of new Unifi OS password length requirements. Changed the password to a longer (12+) length and updated the integration. Now it works again.

Do you have the log output still? Would be nice to improve how to communicate things like that

Kane610 avatar Dec 17 '23 21:12 Kane610

I don't think it's the password. I'm facing the same issue and I have a long password. Also, the integration connects on HA start and when I click reload on the integration.

This is all I see in the logs:

Error connecting to the UniFi Network at 192.168.2.1:

arsaboo avatar Dec 20 '23 13:12 arsaboo

Error connecting to the UniFi Network at 192.168.2.1:

Try restarting UniFi

Kane610 avatar Dec 20 '23 17:12 Kane610

The devices keep going offline. There is something wrong with this integration. I am not sure if Unifi AP is the answer (since I have 3 APs).

arsaboo avatar Dec 22 '23 02:12 arsaboo

I also experience a client device tracker that keeps reverting to away 5 minutes after reloading the integration which is the only way to properly get the real state that I've found. Maybe I should create an automation that reloads the integration every 2 minutes to keep a stable device tracking solution? I'm mostly joking but only mostly

pascal-de-ladurantaye avatar Dec 22 '23 03:12 pascal-de-ladurantaye

I might have some time for debugging over the Holiday break. Hopefully I'll find something

pascal-de-ladurantaye avatar Dec 22 '23 04:12 pascal-de-ladurantaye

same problem here. I have changed the password, removed and added the Dream Router again, but it did not help.

Schwebebahn avatar Dec 22 '23 10:12 Schwebebahn

After setting up a development environment to debug the issue in dev mode, I noticed that I wasn't able to reproduce it. The only difference was the integration setup. In my Dev environment, my user wasn't setup in advanced mode which resulted a simplified setup flow for the Unifi Network integration. Armed with this knowledge, I removed the integration in my prod environment, restarted HA, made my user a non-advanced one and re-created the integration along with my device trackers. I'm happy, and confused, to report that the device tracking has been working as expected since then. I suspect it's an issue with having the previous integration config contain specific SSIDs to track on or because I added the tracking clients without an accompanying network block switch config (I noticed that the switch was still added to my device even if not requested) I'll monitor my new setup and report back if it suddenly stops working again

pascal-de-ladurantaye avatar Dec 23 '23 03:12 pascal-de-ladurantaye

It happened again! At exactly 11PM which is pretty specific. Could it be a timezone issue? Both my Unifi controller and my home assistant are configured with the correct timezone though (UTC-5 Toronto) but I don't think they are configured to use any specific NTP server.

pascal-de-ladurantaye avatar Dec 23 '23 04:12 pascal-de-ladurantaye

I'm still not able to reproduce the issue in my dev environment so my new assumption is that it might be already fixed on the dev branch. I'm currently attempting to override the unifi component with the latest dev version of it using a custom_component.

The only major-ish difference between the 2 versions is https://github.com/home-assistant/core/pull/105691 which does touch device trackers. I'll report tomorrow.

Note that I've also confirmed that both versions are using the same id and unique id.

pascal-de-ladurantaye avatar Dec 25 '23 03:12 pascal-de-ladurantaye

Same issue here, tracked WiFi device keeps returning to away state in HA even though its online the entire time. Seems to happen at random. Reloading the integration restores the tracking for some time. image

edit: Tracking was working fine before I upgraded from USG (Network 8.0.24) to UDM-Pro (Unifi OS 3.2.7 / Network 8.0.24) on thursday, including a reinstall of the HA unifi integration.

ChrisMZ avatar Dec 25 '23 20:12 ChrisMZ

I'm still not able to reproduce the issue in my dev environment so my new assumption is that it might be already fixed on the dev branch. I'm currently attempting to override the unifi component with the latest dev version of it using a custom_component.

The only major-ish difference between the 2 versions is #105691 which does touch device trackers. I'll report tomorrow.

Note that I've also confirmed that both versions are using the same id and unique id.

Just curious how your dev branch is holding up? Still working?

vcdx71 avatar Dec 27 '23 17:12 vcdx71

Sorry, with holiday gatherings, it slipped my mind to report here. Latest dev version in production shows the same issue. Like others said, I see correct device tracking reports for short while after a reload and then everything changes to away at the same time.

I had been meaning to look into ESPresence for a while now and I'm going to experiment with it today. At least as a temporary crutch to the Unifi integration.

pascal-de-ladurantaye avatar Dec 27 '23 18:12 pascal-de-ladurantaye

Thanks for the update. Seeing the same behavior. Seems everyone that is having the issue is on Unifi OS 3.2.7, seems something in this release broke the integration.

vcdx71 avatar Dec 27 '23 18:12 vcdx71

Likely, I'm just not able to reproduce the issue in dev which makes me doubt that it's on Ubiquiti's side. Maybe it's related to request volume? I have the unifiprotect integration running in my real environment and a lot more devices being tracked due to the various other integrations I have running there as well.

pascal-de-ladurantaye avatar Dec 27 '23 18:12 pascal-de-ladurantaye

If new reports are coming in that it was fine before updating to 8.0.24 while running 2023.12.x in Home Assistant, then, yeah, most likely a change in the Network application causing this. In my case, both updates happened on the same day.

pascal-de-ladurantaye avatar Dec 27 '23 18:12 pascal-de-ladurantaye

BTW, I said previously that I was mostly joking talking about reloading the integration every so often... well I did it now. That might be an ok enough crutch for now

alias: Reload Unifi integration every 3 minutes
description: ""
trigger:
  - platform: time_pattern
    minutes: /3
    hours: "*"
    seconds: "0"
condition: []
action:
  - service: homeassistant.reload_config_entry
    data:
      entry_id: 1acf49556e38bed1f9a1818ce85b5fc1
mode: single

The entry ID can be found in .storage/core.config_entries. Find the one for the unifi integration.

Only downside I found so far is that the device trackers become unavailable for a couple seconds every reload

pascal-de-ladurantaye avatar Dec 27 '23 19:12 pascal-de-ladurantaye

Yeah I'm doing the same, just watching the state of one of my networks and when the client count is zero then reloading..

vcdx71 avatar Dec 27 '23 19:12 vcdx71

I have the same problem , keeps reverting to away 5 minutes after reloading. Attribute ap_mac of device_tracker disappears after 5 minutes

jaberhadi avatar Dec 28 '23 05:12 jaberhadi

I have the same issue (since upgrading my UDM-Pro to Unifi OS 3.2.7 / Network 8.0.24). 2 main device trackers appear after a HA reboot for a few hours max before dropping offline again.

margatemarcel avatar Dec 28 '23 12:12 margatemarcel

Adding another +1 here! Seems to be the same behavior, and versions, that everyone else is reporting.

fxfitz avatar Dec 28 '23 17:12 fxfitz