From de35e315f2fcc77bc07b156ed5035e4c3b191bcb Mon Sep 17 00:00:00 2001 From: Thomas D <11554546+thomasddn@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:25:43 +0000 Subject: [PATCH] Fix options flow --- custom_components/volvo_cars/config_flow.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/custom_components/volvo_cars/config_flow.py b/custom_components/volvo_cars/config_flow.py index 7168d9a..13f4871 100644 --- a/custom_components/volvo_cars/config_flow.py +++ b/custom_components/volvo_cars/config_flow.py @@ -159,7 +159,7 @@ def async_get_options_flow( config_entry: ConfigEntry, ) -> OptionsFlowHandler: """Create the options flow.""" - return OptionsFlowHandler() + return OptionsFlowHandler(config_entry) async def _async_authenticate( self, vin: str, user_input: dict[str, Any], errors: dict[str, str] @@ -232,7 +232,9 @@ async def _async_create_or_update_entry(self) -> ConfigFlowResult: ) -class OptionsFlowHandler(config_entries.OptionsFlow): +# OptionsFlowWithConfigEntry is being phased out, probably in 2025.12. +# Use OptionsFlow instead, starting from 2024.12. +class OptionsFlowHandler(config_entries.OptionsFlowWithConfigEntry): """Class to handle the options.""" async def async_step_init( @@ -285,5 +287,7 @@ async def async_step_init( return self.async_show_form( step_id="init", - data_schema=vol.Schema(schema), + data_schema=self.add_suggested_values_to_schema( + vol.Schema(schema), self.config_entry.options + ), )