zachcheatham / ha-omada

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

Omada reload integration. #39

Closed michaeldouble07 closed 1 year ago

michaeldouble07 commented 2 years ago

I run into this condition where I have the home assistant running on docker, and the Omada controller running in Ubuntu, but when I boot HA always shows it has errors, but when I realized the integration the error goes away. My guess is that the Omada controller initializes later and since the integration does not check more than one time, that Omada has started. Is there a way that someone could update this to include a delay and number of retries?

chjohans commented 1 year ago

I second this, most HA integrations will retry n times with a timeout in-between retries. If you have a number of integrations installed/enabled and you look at your Settings -> Devices & Services page in HA during a restart you'll probably see at least one of the "retrying" initialization, most likely because some dependencies are not yet ready.

I consider this a bug, some will probably say it's an improvement.

Anyhow please consider @zachcheatham - and thank you for making this integration available!

zachcheatham commented 1 year ago

Marking this as a bug since ConfigEntryNotReady support was added earlier this year for the behavior @chjohans mentioned.

zachcheatham commented 1 year ago

@michaeldouble07, can you send over the error logs so I can determine which conditions are causing the integration to not automatically retry.

michaeldouble07 commented 1 year ago

The logs are below, this shows that it tries 3 times and is unsuccessful on the third try, my controller takes about 1-1.5 minutes before it is up and running.  The home assistant instance is running through docket and I utilize the loop back adapter to go directly to the controller.It just seems like the attempts are way too frequent, and need to be spaced out more or have more retries.   Mind you this is running on a raspberry pi4 with 8 gb of ram on an SD card that is 128 gb.

This error originated from a custom integration.Logger: homeassistant.config_entriesSource: custom_components/omada/controller.py:146 Integration: TP-Link Omada (documentation) First occurred: 12:26:21 AM (1 occurrences) Last logged: 12:26:21 AMError setting up entry Home: Default for omadaTraceback (most recent call last):  File "/config/custom_components/omada/controller.py", line 147, in get_api_controller    await controller.login()  File "/config/custom_components/omada/api/controller.py", line 48, in login    await self._update_api_info()  File "/config/custom_components/omada/api/controller.py", line 65, in _update_api_info    response = await self._request("get", f"{self.url}/api/info")  File "/config/custom_components/omada/api/controller.py", line 180, in _request    async with self._session.request(  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 1138, in aenter    self._resp = await self._coro  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 559, in _request    await resp.start(conn)  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 898, in start    message, payload = await protocol.read()  # type: ignore[union-attr]  File "/usr/local/lib/python3.10/site-packages/aiohttp/streams.py", line 616, in read    await self._waiterasyncio.exceptions.CancelledErrorDuring handling of the above exception, another exception occurred:Traceback (most recent call last):  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup    result = await component.async_setup_entry(hass, self)  File "/config/custom_components/omada/init.py", line 32, in async_setup_entry    await omada_controller.async_setup()  File "/config/custom_components/omada/controller.py", line 74, in async_setup    self.api = await get_api_controller(  File "/config/custom_components/omada/controller.py", line 146, in get_api_controller    with async_timeout.timeout(10):  File "/usr/local/lib/python3.10/site-packages/async_timeout/init.py", line 116, in exit    self._do_exit(exc_type)  File "/usr/local/lib/python3.10/site-packages/async_timeout/init.py", line 212, in _do_exit    raise asyncio.TimeoutErrorasyncio.exceptions.TimeoutErrorLogger: homeassistant.config_entriesSource: config_entries.py:395 First occurred: 12:25:18 AM (2 occurrences) Last logged: 12:26:11 AMConfig entry 'Home: Default' for omada integration not ready yet: Error connecting to https://127.0.0.1:8043/api/info: Cannot connect to host 127.0.0.1:8043 ssl:default [Connect call failed ('127.0.0.1', 8043)]; Retrying in backgroundConfig entry 'Michael Toczycki' for spotify integration not ready yet: http status: 429, code:-1 - /v1/me/: Max Retries, reason: too many 429 error responses; Retrying in backgroundThis error originated from a custom integration.Logger: custom_components.omada.controllerSource: custom_components/omada/controller.py:74 Integration: TP-Link Omada (documentation) First occurred: 12:25:18 AM (1 occurrences) Last logged: 12:25:18 AMUnable to connect to Omada at https://127.0.0.1:8043: Error connecting to https://127.0.0.1:8043/api/info: Cannot connect to host 127.0.0.1:8043 ssl:default [Connect call failed ('127.0.0.1', 8043)]On Nov 1, 2022, at 1:07 PM, Zach Cheatham @.***> wrote: @michaeldouble07, can you send over the error logs so I can determine which conditions are causing the integration to not automatically retry.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

michaeldouble07 commented 1 year ago

Thanks for fixing this, it takes 3 attempts, then it connects every time I restart my PI. Thanks for fixing this.