From 34bec1c50fdecdcb0edef950ad7723add04fe490 Mon Sep 17 00:00:00 2001 From: Pete Sage <76050312+PeteRager@users.noreply.github.com> Date: Sun, 4 May 2025 12:41:39 -0400 Subject: [PATCH] Avoid delaying HA startup in Rehlko (#144202) --- homeassistant/components/rehlko/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/rehlko/__init__.py b/homeassistant/components/rehlko/__init__.py index 19702527259..49ceb8ac870 100644 --- a/homeassistant/components/rehlko/__init__.py +++ b/homeassistant/components/rehlko/__init__.py @@ -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