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 <marhje52@gmail.com>

* Update docs/config_entries_config_flow_handler.md

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
epenet 2024-10-08 10:18:19 +02:00 committed by GitHub
parent 9504fa4d92
commit c99a54ff6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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