zachcheatham / ha-omada

Home Assistant TP-Link Omada Integration
189 stars 26 forks source link

Integration fails after Home Assistant reboot #19

Closed sbach89 closed 2 years ago

sbach89 commented 2 years ago

Integration fails after every reboot, needs to be removed and re added to enable again.

Omada Software Controller 5.0.29, Home Assistant 2021.12.10 Home Assistant TP-Link Omada Integration 0.2.0

2022-01-27 14:37:27 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Omada: Default for omada
Traceback (most recent call last):
File "/config/custom_components/omada/controller.py", line 157, in get_api_controller
await controller.login()
File "/config/custom_components/omada/api/controller.py", line 60, in login
response = await self._controller_request("post", "/login", json=auth)
File "/config/custom_components/omada/api/controller.py", line 165, in _controller_request
return await self._request(
File "/config/custom_components/omada/api/controller.py", line 190, in _request
async with self._session.request(
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 1138, in __aenter__
self._resp = await self._coro
File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 559, in _request
await resp.start(conn)
File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 898, in start
message, payload = await protocol.read() # type: ignore[union-attr]
File "/usr/local/lib/python3.9/site-packages/aiohttp/streams.py", line 616, in read
await self._waiter
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 313, in async_setup
result = await component.async_setup_entry(hass, self) # type: ignore
File "/config/custom_components/omada/__init__.py", line 30, in async_setup_entry
await controller.async_setup()
File "/config/custom_components/omada/controller.py", line 87, in async_setup
self.api = await get_api_controller(self.hass, self.url, self.username, self.password, self.site, self.verify_ssl)
File "/config/custom_components/omada/controller.py", line 157, in get_api_controller
await controller.login()
File "/usr/local/lib/python3.9/site-packages/async_timeout/__init__.py", line 115, in __exit__
self._do_exit(exc_type)
File "/usr/local/lib/python3.9/site-packages/async_timeout/__init__.py", line 203, in _do_exit
raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError
ssummer commented 2 years ago

I think this is a duplicate of issue #4 that I already reported. As a workaround, what I did was add an automation that restarts the service a couple of minutes after startup and that does work, but it would be nice to get this fixed. My HASS is running on quite an old raspberry pi so possibly the timeout is too short.

sbach89 commented 2 years ago

Hmm it's odd because I didn't have this issue when the integration and controller were on 4.x version. I'm also running on a Celeron J1900 so it isn't exactly slow for what it's doing. Thanks for the tip.

zachcheatham commented 2 years ago

I'm trying to recreate this issue to add in a fix, but unable to. I'm running HA and Omada both in docker containers on a NUC with a Celeron J3455. If I restart the entire box, the integration comes back fine. Restarting both individually seems to work as well.

This appears to be an issue with connectivity when the integration initially loads.

sogood007 commented 2 years ago

I am also running Omada and HA on docker container on the same computer. If I reboot the computer, I have seen cases that the Omada may have start after the HA, so as the integration fail. To fix that, I just need to restart the HA container. I don't recall such problem in v4 Omada.

zachcheatham commented 2 years ago

Marking this as duplicate. We can continue conversation in #4