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.64k stars 30.78k forks source link

All Unifi entities / devices show as "Away" #96095

Closed philippefs35 closed 1 year ago

philippefs35 commented 1 year ago

The problem

All of the entities reported by the Unifi integration show as "Away" even though they are connected

Example: image

What version of Home Assistant Core has the issue?

core-2023.7.1

What was the last working version of Home Assistant Core?

No response

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

config_entry-unifi-be1987dbea0c1a6b4bc507d77b80b8cb.json.txt

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 1 year 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.

(message by CodeOwnersMention)


unifi documentation unifi source (message by IssueLinks)

thekillerpt commented 1 year ago

I have the same issue, when integration starts all devices are located correctly, after 5mn (or whatever is set to define that the devices are away) all devices become away

was working well before , in a previous home assistant + unifi app version

stefanroelofs commented 1 year ago

I had the same issue. All devices were shown as 'away'.

I then tried to remove the Unifi integration and add it again and now the setup will not connect anymore:

2023-07-14 08:29:46.927 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiounifi/controller.py", line 178, in request
    response: list[dict[str, Any]] = await self._request(
                                     ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiounifi/controller.py", line 217, in _request
    raise LoginRequired(f"Call {url} received 401 Unauthorized")
aiounifi.errors.LoginRequired: Call https://192.168.1.224:8443/api/self/sites received 401 Unauthorized

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiounifi/controller.py", line 178, in request
    response: list[dict[str, Any]] = await self._request(
                                     ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiounifi/controller.py", line 217, in _request
    raise LoginRequired(f"Call {url} received 401 Unauthorized")
aiounifi.errors.LoginRequired: Call https://192.168.1.224:8443/api/self/sites received 401 Unauthorized

I run UniFi Network Application 7.4.162

Kane610 commented 1 year ago

What is your operating environment for the Unifi Network app? Since its working for many other users I'd wager its something in your environment.

stefanroelofs commented 1 year ago

It's running as a container under proxmox 6.4. Installed using UniFi network application installation script by Glenn.

Is this the info you need? Thanks.

Op di 1 aug. 2023 23:04 schreef Robert Svensson @.***>:

What is your operating environment for the Unifi Network app?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/96095#issuecomment-1661090372, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJBK7DJ5SDP3PIO55WNTFTTXTFVLZANCNFSM6AAAAAA2B6YZWI . You are receiving this because you commented.Message ID: @.***>

Kane610 commented 1 year ago

Can you share have you tried restarting the container? It seems when users have different types of issues a restart resolves it

stefanroelofs commented 1 year ago

It seems that a restart of the container fixed the issues. Thanks! Unifi integration now installs fine, and also the device tracker for my phone switches from Home to Away. Thanks again.

the01 commented 1 year ago

This seems to be related to #89473

For me, it stopped working a few weeks (months?) back, though I didn't immediately notice. Might have been after a HA update, but the controller remained on the same version. I run the controller in a docker container on the network and updated it in the last couple days. I also tried deleting and re-adding the hub. The devices are found just fine, but the "away" state never changes. Anything else I could try?

Kane610 commented 1 year ago

@the01 Have you tried restarting your controller?

If restarting the controller doesn't help you can enable debug logging for the integration and share the log.

the01 commented 1 year ago

Yes, restarting was part of the controller update as I'm running in a docker container. Just to be sure I did so again, but no change (afterwards I reloaded the integration to cover all bases and also no improvement) I will check the log later, but is there anything specific to look out for (except for errors obviously)? Is 5 minutes of normal operation enough or better a reload? Last time I had a look there was very detailed information on all the devices on my network, so if I can't spot anything myself, I'm going to want to anonymize it a bit first

Kane610 commented 1 year ago

I will check the log later, but is there anything specific to look out for (except for errors obviously)?

Checking that web socket is set up correctly, that new data is flowing over web socket,.

6 minutes of debug log from start up would be great. If you want to limit exposure you can send me the log over discord or ha forums.

the01 commented 1 year ago

Soooo..turns out the issue was time drift on the VM running the controller -.-

When checking the debug log, i validated some of the time stamps in the data and they were ~45min off. I could have sworn I checked this previously, but yeah...

Sorry for the noise and thank you for the help!

Kane610 commented 1 year ago

Thanks for validating! Would be nice to be able to catch that time diff in the api somehow.

OP hasn't been active since creating the issue and the other issues have been resolved so closing this.

the01 commented 1 year ago

Thanks for validating! Would be nice to be able to catch that time diff in the api somehow.

OP hasn't been active since creating the issue and the other issues have been resolved so closing this.

I think it would be possible to detect via the Date header in the api response (at least I see it in the debug log)