home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.68k stars 30.81k forks source link

Unifi Network Intergration no longer updating home status for many devices #104418

Closed mkono87 closed 8 months ago

mkono87 commented 11 months ago

The problem

I have only 2 devices on a 2nd SSID through Unifi and one is used for device_tracking in which the integration has that SSID enabled to track devices. Been about 2 years of it running flawlessly. I have noticed since Nov 18th that both devices are showing as away even though on the unifi controller they are online.

One of the devices is a media player and the other is a cell phone. I thought maybe something was up with the phone, but I know the mediaplayer is online and playing but the integration still marks both of them as zero. I have not tried to bring the phone over to my main network which Home-Assistant is, I figured it shouldn't be a big deal. it just totally stopped working for that subnet.

What version of Home Assistant Core has the issue?

core-2023.11.3

What was the last working version of Home Assistant Core?

d

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Unifi Network

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 11 months 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!

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)

Kane610 commented 11 months ago

So did you do anything with your system around that time? Update UniFi or Home Assistant, things typically don't break without a reason

Some time ago I introduced a new way to select clients to get entities from in the UniFi integration, try going to the integration options and explicitly select those clients from the first drop down

mkono87 commented 11 months ago

So did you do anything with your system around that time? Update UniFi or Home Assistant, things typically don't break without a reason

Some time ago I introduced a new way to select clients to get entities from in the UniFi integration, try going to the integration options and explicitly select those clients from the first drop down

Not that I recall. I um using the linuxservers unifi-controller container. I tried to downgrade it to test but wont start on an old version so I'm reach out to ask them about it. Im setting up a dev environment to test with UnifiAP direct to see if they pop up. Other than that I haven't not changed Unifi at all.

I have also done the entity selection you mentioned that it doesn't change anything.

Kane610 commented 11 months ago

What version of UniFi are you running?

mkono87 commented 11 months ago

What version of UniFi are you running?

8.0.7 but I also tried 7.5 and still no dice. I used one of my own phones to get on that network and it wont bring mark as home in HA. No firewall rules are blocking this send 2nd SSID (other vlan) which it wouldn't matter and its coming through unfi.

Short of blowing out the entire integration and trying again I dont know what the heck is going on.

u3EtXyTiD9 y8hklUZP6n

I even performed surgery removed the phone from core_devices and core_entities. Rebooted it was picked up again from the controller. Yet still "away".

mkono87 commented 11 months ago

Actually its doing it for all mobile devices. I didn't notice because I'm using Zones as well. I removed the Unifi integration, rebooted and added it again. Same issue. All devices show online in Unifi but not in HA. So fricking weird.

mkono87 commented 11 months ago

Update: Everything works as intended with the Unifi AP intergration.

AlexanderGaggl1 commented 11 months ago

How did you finaly solve the issue?

mkono87 commented 11 months ago

How did you finaly solve the issue?

I didnt, I just used the Unifi AP (DIrect) integration instead which you have to do manually in the configuration.yaml. The UI Unifi Network intergration is odd. Its showing all the network appliances as online or home its just all the clients that no longer show the correct status.

Do you have the problem as well?? @AlexanderGaggl1

mkono87 commented 11 months ago

So no one has come across this anywhere else on the net? It seems as if @AlexanderGaggl1 has this problem but not sure why the heck its happening. Alex, how and where are you hosting the unifi controller?

Zynoz commented 11 months ago

I think I am running into the same issue I have the UniFi Network Application up and running successful, configured a device_trigger but the connection changes "home" and "not_home" are not triggering any automations

Kane610 commented 11 months ago

I think I am running into the same issue I have the UniFi Network Application up and running successful, configured a device_trigger but the connection changes "home" and "not_home" are not triggering any automations

If your entities have the expected states then you have a different issue, probably something with your automations.

Kane610 commented 11 months ago

So no one has come across this anywhere else on the net? It seems as if @AlexanderGaggl1 has this problem but not sure why the heck its happening. Alex, how and where are you hosting the unifi controller?

Please share a full debug log of this happening

issue-triage-workflows[bot] commented 11 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

jheddings commented 11 months ago

I believe I'm running into a similar issue... The devices show online in my UniFi device list as active, but after a period of time they show Away in Home Assistant.

When I reload the integration, the devices appear Home for a short time. It appears that when they switch AP's, Home Assistant marks them as "Away" and never recovers. Reloading the integration updates status (assuming the device is present) but ends back up in the same loop.

Nothing suspicious in the logs, or at least not where I know to look. I'm currently in the process of rolling back versions to see if there is one that looks more stable.

Versions:

Kane610 commented 11 months ago

Try restarting UniFi

jheddings commented 10 months ago

Try restarting UniFi

Been there a few times... Restarting the integration seems to get things back online for a bit, but then all device trackers go "away" at the same time after a short (but inconsistent) period of time.

I was able to grab a debug log, which shows steady logging up until exactly 5 minutes before the trackers go "away." Unfortunately, the end of the log is truncated, only a partial debug message:

2023-12-21 07:57:21.880 DEBUG (MainThread) [aiounifi.interfaces.connectivity] {"data":[{"_id":"6503a970895bca3c931a7629", ...
2023-12-21 07:57:21.884 DEBUG (MainThread) [aiounifi.interfaces.connectivity] {"meta":{"rc":"ok","message":"device:sync", ...
2023-12-21 07:57:22.653 DEBUG (MainThread) [aiounifi.interfaces.connectivity] 

I would post the full log, but there seems to be a lot of potentially sensitive data in there. Here is the log volume visualization from Loki, where you can see the abrupt stop to logging traffic:

Screenshot 2023-12-21 at 08 16 31

And the history log for one of the devices (which is still on the local network):

Screenshot 2023-12-21 at 15 42 21

At this point, restarting the integration does update the device status until the condition occurs again. This typically lasts 10-30 minutes.

I've rolled back through several HASS versions but cannot find where this problem started. If I remember correctly, it was around the time of a UniFi Network app update (on Dec 14).

mairas commented 10 months ago

I am suffering from the same issue. When Home Assistant (or just the integration) is restarted, the devices are "Home". After that, I get sporadic "Pixel-6 was detected away" messages in the logbook (every few hours or so) but never "detected at home". I, too, believe the problem started when I updated Home Assistant to 2023.12.3. I am now at 2023.12.4 but the problem persists.

kriebgui1 commented 10 months ago

I have the same issue. A restart of the Integration fix it for a couple of hours. So i created a automation to restart the Unifi Integration every one hour. For the moment this workaround helps me, but is not a good solution.

I found out, that the issue comes with version 2023.8.0 to 2023.8.4. With version <= 2023.7.3 the issue doesn't exists.

Device: Unifi Dream Machine Unifi OS Version: v3.2.9 Network App Version: 8.0.26

Kane610 commented 10 months ago

I've been running a test for 5 hours which didn't replicate this issue on UniFi OS 3.1.16 and Controller 8.0.24

Screenshot 2023-12-28 at 22 52 55

I will upgrade to latest stable UniFi OS 3.2.7 and see if that changes

The logics for a client tracker availability is quite simple to view in the logs

It validates if its a wired or wireless client, then if wireless it will check against the ssid filter, and finally it will validates timestamp of reportedly last seen and makes sure its within the configured detection time limit (default 300 sec).

xinud190 commented 10 months ago

Hi - Experiencing the same problem with latest versions (see below).

Don't think this has anything to do with wireless devices specifically, my UDM Pro appears AWAY but after restarting it appears HOME for a period of time.

HA Integration documentation for Unifi states there is potential for things being marked away if time between HA and Unifi is off:

Presence detection depends on accurate time configuration between Home Assistant and the UniFi Network application.

If Home Assistant and the UniFi Network application are running on separate machines or VMs ensure that all clocks are synchronized. Failing to have synchronized clocks will lead to Home Assistant failing to mark a device as home.

However, I've checked times and everything looks good to me.

Hoping to get this resolved soon. Its a real pain for Automations.


Versions:

Home Assistant: 2023.12.4 UniFi OS: 3.2.7 UniFi Network: 8.0.24

Kane610 commented 10 months ago

Hi - Experiencing the same problem with latest versions (see below).

Don't think this has anything to do with wireless devices specifically, my UDM Pro appears AWAY but after restarting it appears HOME for a period of time.

HA Integration documentation for Unifi states there is potential for things being marked away if time between HA and Unifi is off:

Presence detection depends on accurate time configuration between Home Assistant and the UniFi Network application. If Home Assistant and the UniFi Network application are running on separate machines or VMs ensure that all clocks are synchronized. Failing to have synchronized clocks will lead to Home Assistant failing to mark a device as home.

However, I've checked times and everything looks good to me.

Hoping to get this resolved soon. Its a real pain for Automations.

Versions:

Home Assistant: 2023.12.4 UniFi OS: 3.2.7 UniFi Network: 8.0.24

Look at my comment, enable debug logging for the integration and follow one of your device trackers and see what happens with the last seen timestamp

mairas commented 10 months ago

I enabled debug logging and reloaded the integration. Not sure about the "last seen" timestamp - I'm following the "Last changed" and "Last updated" values of the entity state in the developer tools, and they don't update. The debug logging is extremely verbose and as un-prettified json, a bit hard to follow, but at least the tracked device name and MAC address are repeated all the time. Is there something in the debug log in particular you'd like me to report?

kriebgui1 commented 10 months ago

I'm activated debug logging and disabled my automatic restart of the integration. Now the updating works since 13 hours. Could it be a timing issue, that is not existing if the integration is working in debug log mode? I can definitively say, the integration works well if I use HA version 2023.7.3. All later versions not - I tried it several times during the last 4 months. I'm happy to help with more tests if someone tell me what I have to test or send log files.

Kane610 commented 10 months ago

I'm activated debug logging and disabled my automatic restart of the integration. Now the updating works since 13 hours. Could it be a timing issue, that is not existing if the integration is working in debug log mode? I can definitively say, the integration works well if I use HA version 2023.7.3. All later versions not - I tried it several times during the last 4 months. I'm happy to help with more tests if someone tell me what I have to test or send log files.

Have you had this issue for 4 months? And you're always running the early access versions?

xinud190 commented 10 months ago

For me, these problems started happening consistently last week (Dec 21)

image

UDM Pro upgraded on Dec 14 (with one occurrence of it going offline from HA then - to be expected as part of upgrade):

image

Then since then multiple times a day the UDM Pro (and other Unifii devices go to AWAY):

image

About 2 hours ago, I enabled debugging, reset the Integration which changed devices back to HOME and just now devices went AWAY again so running with Debugging enabled does not seem to change anything.

xinud190 commented 10 months ago

@Kane610 If you would like I could provide debug logs directly to you, but not comfortable with posting publicly.

I've started to parse through and find trend but not seeing anything yet.

Kane610 commented 10 months ago

@Kane610 If you would like I could provide debug logs directly to you, but not comfortable with posting publicly.

I've started to parse through and find trend but not seeing anything yet.

Sure, you can share it with me over the forums or hass discord (Robban)

Kane610 commented 10 months ago

I've upgraded my unifi os to 3.2.7 and doing a test run with my iPhone. Connected for two hours now, let's see if anything changes on the third hour as some have mentioned. Also running detection time on only 20s and seems stable.

Do you have any configurations set for the device tracker? I only use the base config of tracking a client by selecting the specific Mac address

xinud190 commented 10 months ago

Not sure if that was question for me, but no I don't have any configuration sets for the device tracker.

mkono87 commented 10 months ago

Glad to see others on here reporting the same issue. I have been way too busy lately to help with debugging and for now just using the AP integration. Thanks to those working on this.

Kane610 commented 10 months ago

Test is running since 6 hours and iPhone tracker has been positive this whole time.

Kane610 commented 10 months ago

Test is running since 6 hours and iPhone tracker has been positive this whole time.

It ran for 9 hours before I turned it off and the iPhone tracker was active the whole time. Running a new test today with my UDMP tracker.

kriebgui1 commented 10 months ago

Yes with all versions above 2023.7.3 If I go back to 2023.7.3 it works fine

[cid:moovit_logo_983f829e-316e-4bec-bd9d-9a374eaf0e47.png]

MoovIT GmbH Schanzenstraße 29 D-51063 Köln HRB Köln 74531

Jobs bei MoovIThttps://www.moovit.de/jobs/

MoovIT GmbH Geschäftsführer: Wolfgang Felix, Jan Fröhling, Katja Meyer, Rafael Hutter, Tobias Trumpfheller Amtsgericht Köln HRB 74531 UStID DE815339118

Informationen zu unserer Datenverarbeitung unter:https: //www.moovit.de/datenschutz/https://www.moovit.de/datenschutz/ Sie können der Datenverarbeitung jederzeit durch eine Nachricht @.**@.> widersprechen!

Informationen gem. Art. 13 DSGVO zur Nutzung unseres Videokonferenz- und Web-Seminarsystems finden Sie unter: https: //www.moovit.de/dsgvoartikel13/https://www.moovit.de/dsgvoartikel13/


Von: Robert Svensson @.> Gesendet: Friday, December 29, 2023 4:02:28 PM An: home-assistant/core @.> Cc: Guido Kriebel @.>; Comment @.> Betreff: Re: [home-assistant/core] Unifi Network Intergration no longer updating home status for many devices (Issue #104418)

Sie erhalten nicht oft eine E-Mail von @.*** Erfahren Sie, warum dies wichtig isthttps://aka.ms/LearnAboutSenderIdentification

I'm activated debug logging and disabled my automatic restart of the integration. Now the updating works since 13 hours. Could it be a timing issue, that is not existing if the integration is working in debug log mode? I can definitively say, the integration works well if I use HA version 2023.7.3. All later versions not - I tried it several times during the last 4 months. I'm happy to help with more tests if someone tell me what I have to test or send log files.

Have you had this issue for 4 months?

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/104418#issuecomment-1872152537, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BD343LD3LZMNHPMG4TVS3TTYL3LQJAVCNFSM6AAAAAA7X2CPDWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZSGE2TENJTG4. You are receiving this because you commented.Message ID: @.***>

Kane610 commented 10 months ago

I found out, that the issue comes with version 2023.8.0 to 2023.8.4. With version <= 2023.7.3 the issue doesn't exists.

There are no primary changes for 2023.8 so Im stunned :),

Can you try the different versions and see if you can pinpoint which of the versions that are breaking? I guess it would be 2023.8.0

Are any other function of unifi integration affected to you?

How are you running hass?

mairas commented 10 months ago

I did a bit of debugging. I was suspecting that the change in 2023.12.3 would've triggered the bug because that's when most of the people (including myself) have bumped into the issue. So, I refreshed my dev setup (with the latest dev branch) and added the Unifi integration. The device tracker works there fine, regardless of whether the one-character change (which in itself seems absolutely fine and necessary) is applied or not.

Then, I logged into the running container of my "production" HA and applied the same change. It seems like reloading the integration doesn't actually reload the source files. I tried restarting home assistant. While the container got restarted, the changes persisted - maybe the HA sources are mounted from the host to the running container? In any case, this made the problem go away - the device tracker has been working for a couple of hours now.

So, the bugfix in 2023.12.3 has the side-effect that under some circumstances, device tracker stops working. I didn't dig deeper into the issue but maybe this gives you some ideas?

mairas commented 10 months ago

Ah. The production machine device trackers were changed to "away" after all. So, the 2023.12.3 change might not be related, after all.

xinud190 commented 10 months ago

Hi - Just an update from my experiences with this problem. Been working off-line from this thread directly with @Kane610 (THANK YOU for all the great collaboration!).

TLDR Headline - My problem seems to be solved, with no unexpected switching of devices to AWAY and not returning.

However, despite doing some extensive version testing of HA on a test instance (having a Prod HA instance as a baseline), it wasn't a specific version that resolved the problem. It appears the problem was resolved by moving a non-ubiquity device in my rack that was directly below my UDM pro and was generating ALOT of heat.

As soon as I made that physical move of another device and put a fan in between them to cool things more, I haven't had an unexpected switch from HOME to AWAY (consistently resolved by restarting the HA Unifi integration) in 5 days. Prior I was getting atleast 2 occurrences a day. Not one since.

Operating temp of my UDM pro is currently 42 C / 43 C. I don't know what it was prior (really didn't look) so I don't know the difference but its definitely cooler. It was burning to the touch prior to moving it.

So anyway, if you haven't considered it - try cooling the UDM pro see if it makes a difference. Continuing to monitor mine.

Thanks again @Kane610 !!

issue-triage-workflows[bot] commented 9 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

henning-meinhardt commented 9 months ago

problem still persists, not fixed yet, can't use Unifi integration in a reliable way for detection of present/absent devices, going back to PING?

Kane610 commented 9 months ago

problem still persists, not fixed yet, can't use Unifi integration in a reliable way for detection of present/absent devices, going back to PING?

Its been hard to get any understanding of why this happens.

What I've seen mostly by people going to UniFiOS v3.2.9 and Network app v8.0.26 is that the problem resolved itself after that. Have you upgraded to latest releases?

I added more debug logging related to web sockets with HASS 2024.1.4 have you upgraded to that and seen anything new in your logs?

henning-meinhardt commented 9 months ago

I'll do the update of HASS right away, was still on 2023.12.4. I'm running a Unifi UDM Pro with OS v3.2.7, will update that as well and let you know tomorrow if the issue persists with these versions. Kind gegrads Henning

mairas commented 9 months ago

I have my UniFiOS and Network app on the above-mentioned versions. I disabled my restarting automation yesterday to test again. Presence detection worked for about six hours but sure enough, went "away" after that. I still have HASS on 2024.1.0, I'll update and test again.

henning-meinhardt commented 9 months ago

until now everything works fine for > 20 hours. No outages detected ;-)

mairas commented 9 months ago

Now that I am at HASS Core 2024.1.5, I haven't seen any outages either. Seems like the issue has resolved itself.

It's possible there's still something bubbling under, though. The presence detection goes intermittently to "unknown" for exactly 15-16 seconds. This wasn't happening before - but it could also be to some unrelated updates in my Pixel 6 phone, for example. In any case, on my behalf, this issue can be considered resolved. Thank you, Robert et al!

Screenshot 2024-01-25 at 11 35 07
Kane610 commented 9 months ago

Thank you, Robert et al!

I haven't achieved anything but keeping being confused. Happy it resolved itself for you

jheddings commented 9 months ago

Just confirming that this seems to be working again in 2024.1.5 Running for over 24 hours w/out any issues. 🤔

Kane610 commented 9 months ago

Just confirming that this seems to be working again in 2024.1.5 Running for over 24 hours w/out any issues. 🤔

That's not helpful at all 😂 , the problem is not even consistent... Not the funniest thing to figure out

Kane610 commented 9 months ago

I've provided an additional log with the upcoming 2024.2.0 release (https://github.com/home-assistant/core/pull/109167)

By configuring debug logging only for the integration and not library it will not be overly many prints

logger:
  default: info
  logs:
    homeassistant.components.unifi: debug

This log should be seen every minute and then we can conclude if web socket stops altogether 2024-01-30 21:50:24.861 DEBUG (MainThread) [homeassistant.components.unifi] Last received websocket timestamp: 2024-01-30 20:50:24.438440+00:00

issue-triage-workflows[bot] commented 9 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.