Fix ConnectTimeout during wolflink start (#43418)
This commit is contained in:
parent
45618f8054
commit
cccd4d734c
1 changed files with 11 additions and 6 deletions
|
@ -2,13 +2,14 @@
|
|||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from httpcore import ConnectError, ConnectTimeout
|
||||
from httpx import ConnectError, ConnectTimeout
|
||||
from wolf_smartset.token_auth import InvalidAuth
|
||||
from wolf_smartset.wolf_client import FetchFailed, WolfClient
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
from .const import (
|
||||
|
@ -45,7 +46,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||
|
||||
wolf_client = WolfClient(username, password)
|
||||
|
||||
parameters = await fetch_parameters(wolf_client, gateway_id, device_id)
|
||||
try:
|
||||
parameters = await fetch_parameters(wolf_client, gateway_id, device_id)
|
||||
except InvalidAuth:
|
||||
_LOGGER.debug("Authentication failed")
|
||||
return False
|
||||
|
||||
async def async_update_data():
|
||||
"""Update all stored entities for Wolf SmartSet."""
|
||||
|
@ -103,7 +108,7 @@ async def fetch_parameters(client: WolfClient, gateway_id: int, device_id: int):
|
|||
try:
|
||||
fetched_parameters = await client.fetch_parameters(gateway_id, device_id)
|
||||
return [param for param in fetched_parameters if param.name != "Reglertyp"]
|
||||
except (ConnectError, ConnectTimeout) as exception:
|
||||
raise UpdateFailed(f"Error communicating with API: {exception}") from exception
|
||||
except InvalidAuth as exception:
|
||||
raise UpdateFailed("Invalid authentication during update") from exception
|
||||
except (ConnectError, ConnectTimeout, FetchFailed) as exception:
|
||||
raise ConfigEntryNotReady(
|
||||
f"Error communicating with API: {exception}"
|
||||
) from exception
|
||||
|
|
Loading…
Add table
Reference in a new issue