From 2ca5889326ede20d59bceddee1f2823397c96e4c Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 13 Nov 2024 21:50:19 +0000 Subject: [PATCH 1/3] Log a warning when replacing existing config entry with same unique id --- homeassistant/config_entries.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index f1748c6b7fb..3a3e6320b69 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -35,6 +35,7 @@ from .const import ( CONF_NAME, EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP, + PATCH_VERSION, Platform, ) from .core import ( @@ -1483,6 +1484,16 @@ class ConfigEntriesFlowManager( result["handler"], flow.unique_id ) + if existing_entry is not None and PATCH_VERSION == "0.dev0": + # We temporarily restrict this to `dev` to get a feel for how many + # integrations this concerns + report_usage( + "creates a config entry when another entry with the same unique ID " + "exists, causing the old entry to be removed and replaced when it " + "should most likely update the previous entry and abort the flow", + core_behavior=ReportBehavior.LOG, + ) + # 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. From 7c8b95dae6611d0c27ab257b505dbb0990cd0072 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 13 Nov 2024 22:03:58 +0000 Subject: [PATCH 2/3] Exclude mobile_app --- homeassistant/config_entries.py | 1 + 1 file changed, 1 insertion(+) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 3a3e6320b69..0d47e9cf799 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -1492,6 +1492,7 @@ class ConfigEntriesFlowManager( "exists, causing the old entry to be removed and replaced when it " "should most likely update the previous entry and abort the flow", core_behavior=ReportBehavior.LOG, + exclude_integrations={"mobile_app"}, ) # Unload the entry before setting up the new one. From f2f829e1c79b616c8d7e1260b7a697c2fb8bf249 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 13 Nov 2024 22:06:03 +0000 Subject: [PATCH 3/3] Ignore custom integrations --- homeassistant/config_entries.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 0d47e9cf799..57b9765eb87 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -1492,6 +1492,8 @@ class ConfigEntriesFlowManager( "exists, causing the old entry to be removed and replaced when it " "should most likely update the previous entry and abort the flow", core_behavior=ReportBehavior.LOG, + core_integration_behavior=ReportBehavior.LOG, + custom_integration_behavior=ReportBehavior.IGNORE, exclude_integrations={"mobile_app"}, )