fix: guard config flow against concurrent duplicate entries and revert out-of-scope init changes

This commit is contained in:
Joshua King
2026-09-13 14:50:35 -04:00
parent 30fc3eb1d3
commit cc24d50a0e
3 changed files with 40 additions and 24 deletions
-2
View File
@@ -19,11 +19,9 @@ async def async_setup(hass: HomeAssistant, config: dict[str, Any]) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up NestQuest from a config entry."""
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = entry
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
hass.data.setdefault(DOMAIN, {}).pop(entry.entry_id, None)
return True
+2 -5
View File
@@ -18,11 +18,8 @@ class NestQuestConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle the user step of the config flow."""
existing = any(
entry.domain == DOMAIN
for entry in self.hass.config_entries.async_entries(DOMAIN)
)
if existing:
await self.async_set_unique_id(DOMAIN, raise_on_progress=False)
if self._async_in_progress() or self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
if user_input is None: