Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] UniFi Integration doesn't update after connectivity failure #35187

Closed
vistalba opened this issue May 4, 2020 · 18 comments · Fixed by #44108
Closed

[BUG] UniFi Integration doesn't update after connectivity failure #35187

vistalba opened this issue May 4, 2020 · 18 comments · Fixed by #44108
Assignees

Comments

@vistalba
Copy link

vistalba commented May 4, 2020

I use Homeassistant (Hassio) 0.109.3 with UniFi integration.
Controller ist running on a remote host in the same network as homeassistant.
Sometimes (because of a backup job) it looses the connectivity to this host for less than 5 minutes.

In this case that "device_tracker" goes to state "unavailable" and never changes to "hom" or "not_home" until I restart Homeassistant completly.

@Kane610
Copy link
Member

Kane610 commented May 4, 2020

Please follow the template and share enough data

@probot-home-assistant
Copy link

unifi documentation
unifi source
(message by IssueLinks)

@vistalba
Copy link
Author

vistalba commented May 4, 2020

The problem

After network connectivity failure between homeassistant and unifi controller, all device tracker shows unavailable. Also if UniFi controller comes back available and is working fine. Stauts never updated again.

Environment

Homeassistant 0.109.3 (HASSIO)
System: HassOS 3.13
Supervisor Version: 220
UniFi Controller: 5.12.66
Frontend: 20200427.2

  • Home Assistant Core release with the issue: 0.109.3
  • Last working Home Assistant Core release (if known): -
  • Operating environment (Home Assistant/Supervised/Docker/venv): Supervised
  • Integration causing this issue: UniFi
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/unifi

Problem-relevant configuration.yaml

No yaml configuration. Everything done in "Integrations GUI".
Just track WiFi Clients (not wired and not UniFi).
300 Seconds.

Traceback/Error logs

There are no log entries at this moment in HA logs.
I've to enable Debug log and see if there is something more helpful.

Additional information

I can reproduce this issue just by shutting down unifi controller and wait some time the device tracker entity status go to "unavailable". After that start unifi controller again. Status of entity stuck at "unavailable" forever... until reboot of Homeassistant.

@Kane610
Copy link
Member

Kane610 commented May 20, 2020

Hey! How does this look now with 0.110? I can say it works perfectly fine with my dev instance which goes up and down as I put my laptop to sleep or when I leave my home with it. It still returns to proper state later on

@vistalba
Copy link
Author

I still facing in this issue on 0.110.1 resease.

22B4A71E-F860-49F4-BE98-E8696ABEC0FD

On screenshot you can see that is switches from „away“ to „unknown“ and never came back up. Controller was available. I saw the issue this morning and checked if controller is working. Can‘t see any problems. So I restarted HA and after that HA reports „Home“/„Away“ again.

@Kane610
Copy link
Member

Kane610 commented May 24, 2020

Ok. Enable debug and share logs

@vistalba
Copy link
Author

I just enabled the debug log for unifi integration and restarted homeassistant.
After that I just restarted the unifi docker container on the other host.
While restarting all "device_tracker" going to "unknown" and stuck there until HA reboot.

This is how debug output looks like:

2020-05-24 10:19:03 WARNING (MainThread) [homeassistant.config_entries] Config entry for heos not ready yet. Retrying in 80 seconds.
2020-05-24 10:19:20 DEBUG (MainThread) [aiounifi.websocket] Websocket disconnected
2020-05-24 10:19:20 WARNING (MainThread) [homeassistant.components.unifi] Lost connection to UniFi controller
2020-05-24 10:19:20 DEBUG (MainThread) [homeassistant.components.unifi.unifi_entity_base] Updating client entity device_tracker.device1 (b0:19:xx:xx:xx:ac)
2020-05-24 10:19:20 DEBUG (MainThread) [homeassistant.components.unifi.unifi_entity_base] Updating client entity device_tracker.device2 (61:c2:xx:xx:xx:34)
2020-05-24 10:19:20 DEBUG (MainThread) [homeassistant.components.unifi.unifi_entity_base] Updating client entity device_tracker.device3 (cc:d2:xx:xx:xx:48)
2020-05-24 10:19:35 INFO (MainThread) [homeassistant.components.unifi] Will try to reconnect to UniFi controller
2020-05-24 10:19:35 DEBUG (MainThread) [aiounifi.controller] https://unifi.sub.mydomain.com:443/api/login
2020-05-24 10:19:35 DEBUG (MainThread) [aiounifi.controller] 503 text/plain <ClientResponse(https://unifi.sub.mydomain.com:443/api/login) [503 Service Unavailable]>
<CIMultiDictProxy('Date': 'Sun, 24 May 2020 08:19:25 GMT', 'Content-Length': '19', 'Content-Type': 'text/plain; charset=utf-8')>
2020-05-24 10:19:35 DEBUG (MainThread) [aiounifi.websocket] Websocket starting
2020-05-24 10:19:35 ERROR (MainThread) [aiounifi.websocket] Unexpected error 503, message='Invalid response status', url='wss://unifi.sub.mydomain.com:443/wss/s/default/events
2020-05-24 10:19:35 DEBUG (MainThread) [aiounifi.websocket] Websocket disconnected
2020-05-24 10:19:39 INFO (MainThread) [homeassistant.components.websocket_api.http.connection.140660595616784] Connection closed by client
2020-05-24 10:21:34 INFO (MainThread) [homeassistant.components.websocket_api.http.connection.140660642042128] Connection closed by client
2020-05-24 10:21:41 INFO (MainThread) [homeassistant.components.websocket_api.http.connection.140660582004496] Connection closed by client
2020-05-24 10:23:15 WARNING (MainThread) [homeassistant.config_entries] Config entry for heos not ready yet. Retrying in 80 seconds.
2020-05-24 10:24:39 WARNING (MainThread) [homeassistant.config_entries] Config entry for heos not ready yet. Retrying in 80 seconds.
2020-05-24 10:25:14 INFO (MainThread) [homeassistant.components.websocket_api.http.connection.140660577987600] Connection closed by client
2020-05-24 10:26:03 WARNING (MainThread) [homeassistant.config_entries] Config entry for heos not ready yet. Retrying in 80 seconds.
2020-05-24 10:26:04 INFO (MainThread) [homeassistant.components.websocket_api.http.connection.140660577125904] Connection closed by client
2020-05-24 10:26:36 INFO (MainThread) [homeassistant.components.websocket_api.http.connection.140660581113232] Connection closed by client
2020-05-24 10:27:27 WARNING (MainThread) [homeassistant.config_entries] Config entry for heos not ready yet. Retrying in 80 seconds.
2020-05-24 10:28:51 WARNING (MainThread) [homeassistant.config_entries] Config entry for heos not ready yet. Retrying in 80 seconds.
2020-05-24 10:28:51 INFO (MainThread) [homeassistant.components.websocket_api.http.connection.140660575774096] Connection closed by client
2020-05-24 10:30:15 WARNING (MainThread) [homeassistant.config_entries] Config entry for heos not ready yet. Retrying in 80 seconds.

I had to remove some personal information from the log and some lines about other integrations/plugins as well.

After connection closed, there is nothing in the log about unifi integration for at least the next 15 minutes. After that I restarted home assistant and unifi was connected again.

Some additional information about the unifi controller:
Controller is running in a docker container with ingress proxy and a valid LE certificate for the domain unifi.sub.mydomain.com.

@vistalba
Copy link
Author

vistalba commented Jun 3, 2020

@Kane610 any update at this issue? Running into this today again.
Any more info I can provide for help?

@Kane610
Copy link
Member

Kane610 commented Jun 3, 2020

Hi!

I haven't looked into this yet. I'm thinking that it might be the proxy that is the breaking part since the integration is modeled around getting certain responses directly from the controller.

@vistalba
Copy link
Author

vistalba commented Jun 3, 2020

This is possible as the 503 error is generated by rproxy because docker container isn‘t available. But a simple retry after a few minutes should resolve this.

@vistalba
Copy link
Author

Any update? Do you need any additional information?

@Kane610
Copy link
Member

Kane610 commented Jun 26, 2020

Im prioritising other work right now. I'm building up a list of things to do with Unifi down the line.

@vistalba
Copy link
Author

Is there any way to just restart the unifi component instead of whole homeassistant? In this case I could do a simple nodered automation to restart unifi if state = unavailable. But this is not so nice if I has to use "homeassistant.restart" as this could have undesired side effects.

@Kane610
Copy link
Member

Kane610 commented Jun 30, 2020

Not that I'm aware of

@nohn
Copy link
Contributor

nohn commented Oct 15, 2020

Looks like this one is related to #40542

@nohn
Copy link
Contributor

nohn commented Oct 15, 2020

Still reproducible with 0.116.2.

@pedrolamas
Copy link
Contributor

Experiencing this issue myself on 0.117.4.

I'm running Home Assistant Core in a Docker container (not Hassio) in a IoT VLAN, and the controller is on a different Management VLAN, but I've made sure that they can "talk" with each other correctly.

My test scenario is with a Raspberry Pi 3 I have with Windows 10 IoT, connected to the Switch with a PoE adapter:

  • I remotely shutdown the Pi (via Windows 10 IoT admin page)
  • I then wait to show as away in HA (roughly 300s)
  • I do NOT disconnect the Pi from the switch, I just tell the switch to power-cycle the PoE in that port
  • Pi boots up again
  • HA always shows Pi as "Away" even though the Unifi Switch and Controller properly show as connected

@vistalba
Copy link
Author

vistalba commented Nov 6, 2020

@pedrolamas I thinks you've a different issue.

As in my case the issue is the lost connectivity between HA <-> Unifi Controller and the entities are "unavailable".
May you should open another issue for this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants