Avoid delaying HA startup in Rehlko (#144202)

This commit is contained in:
Pete Sage 2025-05-04 12:41:39 -04:00 committed by Paulus Schoutsen
parent 1d0c520f64
commit 34bec1c50f

View File

@ -40,7 +40,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: RehlkoConfigEntry) -> bo
)
rehlko.set_refresh_token_callback(async_refresh_token_update)
rehlko.set_retry_policy(retry_count=3, retry_delays=[5, 10, 20])
try:
await rehlko.authenticate(
@ -48,6 +47,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: RehlkoConfigEntry) -> bo
entry.data[CONF_PASSWORD],
entry.data.get(CONF_REFRESH_TOKEN),
)
homes = await rehlko.get_homes()
except AuthenticationError as ex:
raise ConfigEntryAuthFailed(
translation_domain=DOMAIN,
@ -60,7 +60,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: RehlkoConfigEntry) -> bo
translation_key="cannot_connect",
) from ex
coordinators: dict[int, RehlkoUpdateCoordinator] = {}
homes = await rehlko.get_homes()
entry.runtime_data = RehlkoRuntimeData(
coordinators=coordinators,
@ -86,6 +85,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: RehlkoConfigEntry) -> bo
await coordinator.async_config_entry_first_refresh()
coordinators[device_id] = coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
# Retrys enabled after successful connection to prevent blocking startup
rehlko.set_retry_policy(retry_count=3, retry_delays=[5, 10, 20])
return True