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

Handle ClientConnectorError in Netatmo data handler #99116

Merged
merged 3 commits into from
Oct 7, 2023

Commits on Aug 27, 2023

  1. Update data_handler.py

    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)]
    AnilDaoud committed Aug 27, 2023
    Configuration menu
    Copy the full SHA
    0d8ebf7 View commit details
    Browse the repository at this point in the history
  2. Update data_handler.py

    fix ruff check
    AnilDaoud committed Aug 27, 2023
    Configuration menu
    Copy the full SHA
    ee3c517 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e41f235 View commit details
    Browse the repository at this point in the history