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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user