From 0f65f56f701a2ec2d286a3ac23c0a4b9ea05a84c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 1 Jul 2020 11:32:21 -0700 Subject: [PATCH] Update config_entries_options_flow_handler.md --- docs/config_entries_options_flow_handler.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/config_entries_options_flow_handler.md b/docs/config_entries_options_flow_handler.md index f6f60eab..b84e1256 100644 --- a/docs/config_entries_options_flow_handler.md +++ b/docs/config_entries_options_flow_handler.md @@ -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. ```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`. @@ -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): """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() +```