Fix homewizard api close not being awaited on unload (#122324)

This commit is contained in:
Marc Mueller 2024-07-22 10:19:08 +02:00 committed by GitHub
parent 02c64c7861
commit c70e611822
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,7 +10,7 @@ from .coordinator import HWEnergyDeviceUpdateCoordinator
type HomeWizardConfigEntry = ConfigEntry[HWEnergyDeviceUpdateCoordinator]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: HomeWizardConfigEntry) -> bool:
"""Set up Homewizard from a config entry."""
coordinator = HWEnergyDeviceUpdateCoordinator(hass)
try:
@ -35,13 +35,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.config_entries.flow.async_abort(progress_flow["flow_id"])
# Finalize
entry.async_on_unload(coordinator.api.close)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_unload_entry(hass: HomeAssistant, entry: HomeWizardConfigEntry) -> bool:
"""Unload a config entry."""
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
entry.runtime_data.api.close()
return unload_ok
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)