Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions custom_components/meross_cloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from datetime import datetime, timedelta
from typing import List, Tuple, Dict, Optional, Collection

import aiohttp
import homeassistant.helpers.config_validation as cv
import voluptuous as vol
from homeassistant import config_entries
Expand Down Expand Up @@ -149,6 +150,9 @@ async def initial_setup(self):
raise ConfigEntryAuthFailed from err
except HttpApiError as err:
raise ConfigEntryNotReady(f"Error communicating with API: {err}") from err
except (aiohttp.ClientError, asyncio.TimeoutError) as err:
# Transient transport failure: retry setup rather than give up
raise ConfigEntryNotReady(f"Error communicating with API: {err}") from err

# If a new token was issued, store it into the current entry
if creds_renewed:
Expand Down Expand Up @@ -469,6 +473,13 @@ def _http_api_polled(*args, **kwargs):
log_exception(msg, logger=_LOGGER)
raise ConfigEntryNotReady()

except (aiohttp.ClientError, asyncio.TimeoutError) as ex:
# Cloud unreachable at setup time (DNS not up yet at boot, WAN down):
# retry with backoff instead of failing the entry permanently
msg = "Could not reach the Meross cloud while setting up the integration."
log_exception(msg, logger=_LOGGER)
raise ConfigEntryNotReady(msg) from ex


async def update_listener(hass, entry):
"""Handle options update."""
Expand Down