From 23acc3161635e25753d0281cf6a4457d9998fc2a Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 21 Nov 2024 16:33:43 +0100 Subject: [PATCH] Improve comments in ConfigEntriesFlowManager.async_finish_flow (#131175) --- homeassistant/config_entries.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 58d9c9c728f32..a33f21fa22f7b 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -1482,8 +1482,6 @@ async def async_finish_flow( ) # Unload the entry before setting up the new one. - # We will remove it only after the other one is set up, - # so that device customizations are not getting lost. if existing_entry is not None and existing_entry.state.recoverable: await self.config_entries.async_unload(existing_entry.entry_id) @@ -1506,12 +1504,14 @@ async def async_finish_flow( ) if existing_entry is not None: - # Unload and remove the existing entry + # Unload and remove the existing entry, but don't clean up devices and + # entities until the new entry is added await self.config_entries._async_remove(existing_entry.entry_id) # noqa: SLF001 await self.config_entries.async_add(entry) if existing_entry is not None: # Clean up devices and entities belonging to the existing entry + # which are not present in the new entry self.config_entries._async_clean_up(existing_entry) # noqa: SLF001 result["result"] = entry