jjlawren / sonos_cloud

Sonos cloud API integration for Home Assistant with improved TTS/alerts handling
121 stars 5 forks source link

Integration not trying to reload when config entry initialization has failed #41

Closed mathieu-mp closed 1 year ago

mathieu-mp commented 1 year ago

Hi, thanks for this integration I use every day !!!

My internet was down when restarting Home Assistant, and Sonos Cloud where not able to initialize. The issue is that Sonos Cloud integration did not try to reload later, as did most of the other integrations. So the integration stayed down event after internet was back up.

This error originated from a custom integration.

Logger: homeassistant.config_entries
Source: custom_components/sonos_cloud/api.py:22
Integration: Sonos Cloud (documentation, issues)
First occurred: December 28, 2022 at 16:10:26 (1 occurrences)
Last logged: December 28, 2022 at 16:10:26

Error setting up entry Sonos Cloud (TTS) for sonos_cloud
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1154, in _create_direct_connection
    hosts = await asyncio.shield(host_resolved)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 880, in _resolve_host
    addrs = await self._resolver.resolve(host, port, family=self._family)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/resolver.py", line 33, in resolve
    infos = await self._loop.getaddrinfo(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 860, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 372, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/sonos_cloud/__init__.py", line 75, in async_setup_entry
    result = await session.async_request("get", url)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 485, in async_request
    await self.async_ensure_token_valid()
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 475, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 89, in async_refresh_token
    new_token = await self._async_refresh_token(token)
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 179, in _async_refresh_token
    new_token = await self._token_request(
  File "/config/custom_components/sonos_cloud/api.py", line 22, in _token_request
    resp = await session.post(self.token_url, data=data, headers=headers)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1166, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.sonos.com:443 ssl:default [Try again]