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
Handle ClientConnectorError in Netatmo data handler #99116
Conversation
adding handler for this exception 2023-08-27 13:21:41.684 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/opt/homeassistant/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 "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection raise exceptions[0] File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection sock = await self._connect_sock( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock await self.sock_connect(sock, address) File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect return await fut ^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionRefusedError: [Errno 61] Connect call failed ('51.145.143.28', 443) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/opt/homeassistant/lib/python3.11/site-packages/homeassistant/components/netatmo/data_handler.py", line 173, in async_update await self.async_fetch_data(publisher) File "/opt/homeassistant/lib/python3.11/site-packages/homeassistant/components/netatmo/data_handler.py", line 200, in async_fetch_data await getattr(self.account, self.publisher[signal_name].method)( File "/opt/homeassistant/lib/python3.11/site-packages/pyatmo/account.py", line 73, in async_update_status resp = await self.auth.async_post_api_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homeassistant/lib/python3.11/site-packages/pyatmo/auth.py", line 351, in async_post_api_request return await self.async_post_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homeassistant/lib/python3.11/site-packages/pyatmo/auth.py", line 376, in async_post_request async with self.websession.post( File "/opt/homeassistant/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in __aenter__ self._resp = await self._coro ^^^^^^^^^^^^^^^^ File "/opt/homeassistant/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request conn = await self._connector.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homeassistant/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect proto = await self._create_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homeassistant/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection _, proto = await self._create_direct_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homeassistant/lib/python3.11/site-packages/aiohttp/connector.py", line 1209, in _create_direct_connection raise last_exc File "/opt/homeassistant/lib/python3.11/site-packages/aiohttp/connector.py", line 1178, in _create_direct_connection transp, proto = await self._wrap_create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homeassistant/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 api.netatmo.com:443 ssl:default [Connect call failed ('51.145.143.28', 443)]
Hey there @cgtobi, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Please fill out the PR template and make sure that CI checks pass. |
fix ruff check
done, fixed order of imports, but there is now one more check in error that i don't know how to handle. Check warning on line 217 in homeassistant/components/netatmo/data_handler.py @codecovcodecov |
It means the test coverage is missing for the lines you added. Please add new tests that ensure the working of the code you've added. ../Frenck |
Checked it out locally. The lines around it don't have tests either. The general threshold for this integration is still ok. So I'll go ahead and merge this in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @AnilDaoud 👍
../Frenck
adding handler for this exception. please merge if appropriate
Breaking change
Proposed change
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: