From c91ecd8da3aa81dcaf0e96a0dcd254944cb1f75a Mon Sep 17 00:00:00 2001 From: Daniel <49846893+danielbrunt57@users.noreply.github.com> Date: Sun, 21 Jul 2024 02:25:18 -0700 Subject: [PATCH] fix: use `config_flow` in OptionsFlow Handler(#2343) closes #2333 --- custom_components/alexa_media/config_flow.py | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/custom_components/alexa_media/config_flow.py b/custom_components/alexa_media/config_flow.py index 125bee57..8b8eb9bf 100644 --- a/custom_components/alexa_media/config_flow.py +++ b/custom_components/alexa_media/config_flow.py @@ -823,7 +823,9 @@ def _update_schema_defaults(self) -> Any: @staticmethod @callback - def async_get_options_flow(config_entry): + def async_get_options_flow( + config_entry: config_entries.ConfigEntry, + ) -> config_entries.OptionsFlow: """Get the options flow for this handler.""" return OptionsFlowHandler(config_entry) @@ -846,37 +848,37 @@ async def async_step_init( ( vol.Optional( CONF_INCLUDE_DEVICES, - default=self.config.get(CONF_INCLUDE_DEVICES, ""), + default=self.config_entry.data.get(CONF_INCLUDE_DEVICES, ""), ), str, ), ( vol.Optional( CONF_EXCLUDE_DEVICES, - default=self.config.get(CONF_EXCLUDE_DEVICES, ""), + default=self.config_entry.data.get(CONF_EXCLUDE_DEVICES, ""), ), str, ), ( vol.Optional( CONF_SCAN_INTERVAL, - default=self.config.get( - CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL - ), + default=self.config_entry.data.get(CONF_SCAN_INTERVAL, 120), ), int, ), ( vol.Optional( CONF_QUEUE_DELAY, - default=self.config.get(CONF_QUEUE_DELAY, DEFAULT_QUEUE_DELAY), + default=self.config_entry.data.get( + CONF_QUEUE_DELAY, DEFAULT_QUEUE_DELAY + ), ), float, ), ( vol.Optional( CONF_EXTENDED_ENTITY_DISCOVERY, - default=self.config.get( + default=self.config_entry.data.get( CONF_EXTENDED_ENTITY_DISCOVERY, DEFAULT_EXTENDED_ENTITY_DISCOVERY, ), @@ -885,7 +887,8 @@ async def async_step_init( ), ( vol.Optional( - CONF_DEBUG, default=self.config.get(CONF_DEBUG, DEFAULT_DEBUG) + CONF_DEBUG, + default=self.config_entry.data.get(CONF_DEBUG, DEFAULT_DEBUG), ), bool, ), @@ -908,6 +911,7 @@ async def async_step_init( user_input[CONF_OTPSECRET] = self.config_entry.data[CONF_OTPSECRET] if CONF_OAUTH in self.config_entry.data: user_input[CONF_OAUTH] = self.config_entry.data[CONF_OAUTH] + self.hass.config_entries.async_update_entry( self.config_entry, data=user_input, options=self.config_entry.options )