1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Add new helper for matching reauth/reconfigure config flows (#127565)

This commit is contained in:
epenet
2024-10-08 10:07:36 +02:00
committed by GitHub
parent 15a1a83729
commit 2c664efb3c
5 changed files with 102 additions and 39 deletions

View File

@@ -2432,6 +2432,26 @@ class ConfigFlow(ConfigEntryBaseFlow):
self._async_current_entries(include_ignore=False), match_dict
)
@callback
def _abort_if_unique_id_mismatch(
self,
*,
reason: str = "unique_id_mismatch",
) -> None:
"""Abort if the unique ID does not match the reauth/reconfigure context.
Requires strings.json entry corresponding to the `reason` parameter
in user visible flows.
"""
if (
self.source == SOURCE_REAUTH
and self._get_reauth_entry().unique_id != self.unique_id
) or (
self.source == SOURCE_RECONFIGURE
and self._get_reconfigure_entry().unique_id != self.unique_id
):
raise data_entry_flow.AbortFlow(reason)
@callback
def _abort_if_unique_id_configured(
self,