Update config_entries_options_flow_handler.md

This commit is contained in:
Paulus Schoutsen 2020-07-01 11:32:21 -07:00 committed by GitHub
parent f6c0952b01
commit 0f65f56f70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,7 +47,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
If the component should act on updated options, you can register an update listener to the config entry that will be called when the entry is updated. If the component should act on updated options, you can register an update listener to the config entry that will be called when the entry is updated.
```python ```python
entry.add_update_listener(update_listener) unsub = entry.add_update_listener(update_listener)
``` ```
The Listener shall be an async function that takes the same input as async_setup_entry. Options can then be accessed from `entry.options`. The Listener shall be an async function that takes the same input as async_setup_entry. Options can then be accessed from `entry.options`.
@ -56,3 +56,9 @@ The Listener shall be an async function that takes the same input as async_setup
async def update_listener(hass, entry): async def update_listener(hass, entry):
"""Handle options update.""" """Handle options update."""
``` ```
Don't forget to unsubscribe the update listener when your config entry is unloaded. You can do this by calling the unsubscribe function returned from adding the listener:
```python
unsub()
```