From 6c00d02d0ba235f94e96c0bcdb8bc4951bba3e52 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 27 Feb 2024 11:55:38 -1000 Subject: [PATCH] Use eager_start for shelly task creation (#111671) --- homeassistant/components/shelly/__init__.py | 4 ++-- homeassistant/components/shelly/coordinator.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/shelly/__init__.py b/homeassistant/components/shelly/__init__.py index 142b5f9c521..4895e2a1a2b 100644 --- a/homeassistant/components/shelly/__init__.py +++ b/homeassistant/components/shelly/__init__.py @@ -208,7 +208,7 @@ async def _async_setup_block_entry(hass: HomeAssistant, entry: ConfigEntry) -> b data["model"] = device.settings["device"]["type"] hass.config_entries.async_update_entry(entry, data=data) - hass.async_create_task(_async_block_device_setup()) + hass.async_create_task(_async_block_device_setup(), eager_start=True) if sleep_period == 0: # Not a sleeping device, finish setup @@ -298,7 +298,7 @@ async def _async_setup_rpc_entry(hass: HomeAssistant, entry: ConfigEntry) -> boo data[CONF_SLEEP_PERIOD] = get_rpc_device_wakeup_period(device.status) hass.config_entries.async_update_entry(entry, data=data) - hass.async_create_task(_async_rpc_device_setup()) + hass.async_create_task(_async_rpc_device_setup(), eager_start=True) if sleep_period == 0: # Not a sleeping device, finish setup diff --git a/homeassistant/components/shelly/coordinator.py b/homeassistant/components/shelly/coordinator.py index 4cb53fd5bea..4afe66199f0 100644 --- a/homeassistant/components/shelly/coordinator.py +++ b/homeassistant/components/shelly/coordinator.py @@ -602,10 +602,10 @@ class ShellyRpcCoordinator(ShellyCoordinatorBase[RpcDevice]): ) -> None: """Handle device update.""" if update_type is RpcUpdateType.INITIALIZED: - self.hass.async_create_task(self._async_connected()) + self.hass.async_create_task(self._async_connected(), eager_start=True) self.async_set_updated_data(None) elif update_type is RpcUpdateType.DISCONNECTED: - self.hass.async_create_task(self._async_disconnected()) + self.hass.async_create_task(self._async_disconnected(), eager_start=True) elif update_type is RpcUpdateType.STATUS: self.async_set_updated_data(None) if self.sleep_period: @@ -619,7 +619,7 @@ class ShellyRpcCoordinator(ShellyCoordinatorBase[RpcDevice]): self.device.subscribe_updates(self._async_handle_update) if self.device.initialized: # If we are already initialized, we are connected - self.hass.async_create_task(self._async_connected()) + self.hass.async_create_task(self._async_connected(), eager_start=True) async def shutdown(self) -> None: """Shutdown the coordinator.""" @@ -701,4 +701,4 @@ async def async_reconnect_soon(hass: HomeAssistant, entry: ConfigEntry) -> None: and (entry_data := get_entry_data(hass).get(entry.entry_id)) and (coordinator := entry_data.rpc) ): - hass.async_create_task(coordinator.async_request_refresh()) + hass.async_create_task(coordinator.async_request_refresh(), eager_start=True)