Use eager_start for shelly task creation (#111671)

This commit is contained in:
J. Nick Koston 2024-02-27 11:55:38 -10:00 committed by GitHub
parent 99c1912ccd
commit 6c00d02d0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View file

@ -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

View file

@ -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)