Skip to content

Commit

Permalink
Improve comments in ConfigEntriesFlowManager.async_finish_flow (#131175)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Nov 21, 2024
1 parent d854940 commit 23acc31
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions homeassistant/config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit 23acc31

Please sign in to comment.