From 7527e87e263661ef8b9778237653b4bc42e4dc28 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 28 Feb 2024 16:00:47 -1000 Subject: [PATCH] Fix steamist blocking startup by waiting for discovery (#111789) Fix steamist blocking statup by waiting for discovery --- homeassistant/components/steamist/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/steamist/__init__.py b/homeassistant/components/steamist/__init__.py index ee46d644847..e84615b9352 100644 --- a/homeassistant/components/steamist/__init__.py +++ b/homeassistant/components/steamist/__init__.py @@ -14,7 +14,7 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.typing import ConfigType -from .const import DISCOVER_SCAN_TIMEOUT, DISCOVERY, DOMAIN, STARTUP_SCAN_TIMEOUT +from .const import DISCOVER_SCAN_TIMEOUT, DISCOVERY, DOMAIN from .coordinator import SteamistDataUpdateCoordinator from .discovery import ( async_discover_device, @@ -32,14 +32,16 @@ CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the steamist component.""" domain_data = hass.data.setdefault(DOMAIN, {}) - domain_data[DISCOVERY] = await async_discover_devices(hass, STARTUP_SCAN_TIMEOUT) + domain_data[DISCOVERY] = [] async def _async_discovery(*_: Any) -> None: async_trigger_discovery( hass, await async_discover_devices(hass, DISCOVER_SCAN_TIMEOUT) ) - async_trigger_discovery(hass, domain_data[DISCOVERY]) + hass.async_create_background_task( + _async_discovery(), "steamist-discovery", eager_start=True + ) async_track_time_interval(hass, _async_discovery, DISCOVERY_INTERVAL) return True