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

Exception when cannot find plug #90

Open
CestLaGalere opened this issue Jun 14, 2023 · 0 comments
Open

Exception when cannot find plug #90

CestLaGalere opened this issue Jun 14, 2023 · 0 comments

Comments

@CestLaGalere
Copy link

CestLaGalere commented Jun 14, 2023

Firstly a good integration, thanks.
I have the Home Assistant Tapo Integration 1.6.1 which uses this library (so forgive me if I am in the wrong place but assumed it should be in this comms library)

When the plug is turned off or disconnected, I get a set of exceptions in the log rather than a graceful error:
Expected behaviour:
the library catch this and output a single line of error that the plug cannot be contacted

Thanks

extract from log:
homeassistant.exceptions.ConfigEntryNotReady: Error communication with API: Cannot connect to host 192.168.1.58:80 ssl:default [Connect call failed ('192.168.1.58', 80)]
2023-06-14 11:57:04.342 WARNING (MainThread) [homeassistant.config_entries] Config entry 'TP8' for tapo integration not ready yet: Error communication with API: Cannot connect to host 192.168.1.58:80 ssl:default [Connect call failed ('192.168.1.58', 80)]; Retrying in background
2023-06-14 11:57:04.346 ERROR (MainThread) [custom_components.tapo.common_setup] Failed to setup Error communication with API: Cannot connect to host 192.168.1.54:80 ssl:default [Connect call failed ('192.168.1.54', 80)]
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
sock = await self._connect_sock(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
return await fut
^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.1.54', 80)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/config/custom_components/tapo/common_setup.py", line 113, in _async_update_data
return await self._update_with_fallback()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/tapo/common_setup.py", line 128, in _update_with_fallback
await self.api.login()
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
raise last_exc
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 988, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.1.54:80 ssl:default [Connect call failed ('192.168.1.54', 80)]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/tapo/common_setup.py", line 117, in _async_update_data
raise UpdateFailed(f"Error communication with API: {str(error)}") from error
homeassistant.helpers.update_coordinator.UpdateFailed: Error communication with API: Cannot connect to host 192.168.1.54:80 ssl:default [Connect call failed ('192.168.1.54', 80)]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/config/custom_components/tapo/common_setup.py", line 74, in setup_tapo_coordinator
await coordinator.async_config_entry_first_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in async_config_entry_first_refresh
raise ex

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

No branches or pull requests

1 participant