From 22327cc01aedb25220652481e5858f1d6ff62587 Mon Sep 17 00:00:00 2001 From: myTselection Date: Sun, 14 Jul 2024 23:24:20 +0200 Subject: [PATCH] fix await async setup --- custom_components/myenergy/__init__.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/custom_components/myenergy/__init__.py b/custom_components/myenergy/__init__.py index 43ec975..d454f2d 100644 --- a/custom_components/myenergy/__init__.py +++ b/custom_components/myenergy/__init__.py @@ -48,11 +48,10 @@ async def async_setup(hass: HomeAssistant, config: dict): except ValueError: pass - hass.async_create_task( - await hass.config_entries.flow.async_init( + await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data={} ) - ) + return True async def async_update_options(hass: HomeAssistant, config_entry: ConfigEntry): @@ -72,9 +71,8 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry): async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up component as config entry.""" - hass.async_create_task( - await hass.config_entries.async_forward_entry_setup(config_entry, Platform.SENSOR) - ) + await hass.config_entries.async_forward_entry_setup(config_entry, Platform.SENSOR) + config_entry.async_on_unload(config_entry.add_update_listener(update_listener)) # _LOGGER.info(f"{DOMAIN} register_services") # register_services(hass, config_entry)