mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Fix ConnectTimeout during wolflink start (#43418)
This commit is contained in:
parent
45618f8054
commit
cccd4d734c
@ -2,13 +2,14 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from httpcore import ConnectError, ConnectTimeout
|
from httpx import ConnectError, ConnectTimeout
|
||||||
from wolf_smartset.token_auth import InvalidAuth
|
from wolf_smartset.token_auth import InvalidAuth
|
||||||
from wolf_smartset.wolf_client import FetchFailed, WolfClient
|
from wolf_smartset.wolf_client import FetchFailed, WolfClient
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -45,7 +46,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
|
|
||||||
wolf_client = WolfClient(username, password)
|
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():
|
async def async_update_data():
|
||||||
"""Update all stored entities for Wolf SmartSet."""
|
"""Update all stored entities for Wolf SmartSet."""
|
||||||
@ -103,7 +108,7 @@ async def fetch_parameters(client: WolfClient, gateway_id: int, device_id: int):
|
|||||||
try:
|
try:
|
||||||
fetched_parameters = await client.fetch_parameters(gateway_id, device_id)
|
fetched_parameters = await client.fetch_parameters(gateway_id, device_id)
|
||||||
return [param for param in fetched_parameters if param.name != "Reglertyp"]
|
return [param for param in fetched_parameters if param.name != "Reglertyp"]
|
||||||
except (ConnectError, ConnectTimeout) as exception:
|
except (ConnectError, ConnectTimeout, FetchFailed) as exception:
|
||||||
raise UpdateFailed(f"Error communicating with API: {exception}") from exception
|
raise ConfigEntryNotReady(
|
||||||
except InvalidAuth as exception:
|
f"Error communicating with API: {exception}"
|
||||||
raise UpdateFailed("Invalid authentication during update") from exception
|
) from exception
|
||||||
|
Loading…
x
Reference in New Issue
Block a user