From c99a54ff6cbaaabdbea208fec64f66decd2e4d46 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 8 Oct 2024 10:18:19 +0200 Subject: [PATCH] Document _abort_if_unique_id_mismatch helper (#2353) * Document _abort_if_unique_id_mismatch helper * Update docs/config_entries_config_flow_handler.md Co-authored-by: Martin Hjelmare * Update docs/config_entries_config_flow_handler.md Co-authored-by: Martin Hjelmare --------- Co-authored-by: Martin Hjelmare --- docs/config_entries_config_flow_handler.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/config_entries_config_flow_handler.md b/docs/config_entries_config_flow_handler.md index 52fc4cd3..e8dc1bd1 100644 --- a/docs/config_entries_config_flow_handler.md +++ b/docs/config_entries_config_flow_handler.md @@ -291,8 +291,9 @@ class ExampleConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): ) ``` -Please note that checking whether you are in a reconfigure flow can be done using `if self.source == SOURCE_RECONFIGURE`. +Checking whether you are in a reconfigure flow can be done using `if self.source == SOURCE_RECONFIGURE`. It is also possible to access the corresponding config entry using `self._get_reconfigure_entry()`. +Ensuring that the `unique_id` is unchanged should be done using `await self.async_set_unique_id` followed by `self._abort_if_unique_id_mismatch()`. ## Reauthentication @@ -387,8 +388,10 @@ Authentication failures (such as a revoked oauth token) can be a little tricky t Automated tests should verify that the reauth flow updates the existing config entry and does not create additional entries. -Please note that checking whether you are in a reauthentication flow can be done using `if self.source == SOURCE_REAUTH`. +Checking whether you are in a reauth flow can be done using `if self.source == SOURCE_REAUTH`. It is also possible to access the corresponding config entry using `self._get_reauth_entry()`. +Ensuring that the `unique_id` is unchanged should be done using `await self.async_set_unique_id` followed by `self._abort_if_unique_id_mismatch()`. + ## Testing your config flow