zachcheatham / ha-omada

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

asyncio.exceptions.TimeoutError after HA restart #4

Closed ssummer closed 2 years ago

ssummer commented 2 years ago

I get the below error every time I restart HA and the Omada integration fails to work. I have to manually call the homeassistant.reload_config_entry service and specify both my access point devices and then it starts to work.

I am using a fairly low spec. raspberry pi to run HA/HAOS - is this a timeout in the integration itself? Is it just that this timeout is set too low? Could this be increased?

Regards,

Stephen

Logger: homeassistant.config_entries Source: custom_components/omada/controller.py:160 Integration: TP-Link Omada (documentation) First occurred: 14:44:22 (1 occurrences) Last logged: 14:44:22

Error setting up entry Omada Controller_50PoW: Default for omada Traceback (most recent call last): File "/config/custom_components/omada/controller.py", line 160, in get_api_controller await controller.login() File "/config/custom_components/omada/api/controller.py", line 41, in login response = await self._public_request("post", "/login", json=auth) File "/config/custom_components/omada/api/controller.py", line 73, in _public_request return await self._request(method, url, json=json) File "/config/custom_components/omada/api/controller.py", line 79, in _request async with self._session.request(method, url, params=params, json=json, ssl=self._ssl_context) as res: File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 1117, in aenter self._resp = await self._coro File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 520, in _request conn = await self._connector.connect( File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 535, in connect proto = await self._create_connection(req, traces, timeout) File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 892, in _createconnection , proto = await self._create_direct_connection(req, traces, timeout) File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection transp, proto = await self._wrap_create_connection( File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1081, in create_connection transport, protocol = await self._create_connection_transport( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1111, in _create_connection_transport await 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 304, 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 91, 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 160, in get_api_controller await controller.login() File "/usr/local/lib/python3.9/site-packages/async_timeout/init.py", line 45, in exit self._do_exit(exc_type) File "/usr/local/lib/python3.9/site-packages/async_timeout/init.py", line 92, in _do_exit raise asyncio.TimeoutError asyncio.exceptions.TimeoutError

massive commented 2 years ago

I'm having exactly same issue. Thanks @ssummer for the workaround. It seems I can make it work after a failed load by just reloading the entry for the router.

zachcheatham commented 2 years ago

Home Assistant seems to have some exceptions that can be thrown during setup that will cause it to retry setup during a temporary failure. I tested by stopping my Omada container and restarting Home Assistant. After adding the exceptions, this integration seems to be successfully reconnecting now once Omada comes back online.