diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index f9e72a723a4..0682d46924d 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -3127,6 +3127,10 @@ class OptionsFlow(ConfigEntryBaseFlow): ) self._config_entry = value + def initialize_options(self, config_entry: ConfigEntry) -> None: + """Initialize the options to a mutable copy of the config entry options.""" + self._options = deepcopy(dict(config_entry.options)) + @property def options(self) -> dict[str, Any]: """Return a mutable copy of the config entry options. @@ -3135,7 +3139,7 @@ class OptionsFlow(ConfigEntryBaseFlow): can only be referenced after initialisation. """ if not hasattr(self, "_options"): - self._options = deepcopy(dict(self.config_entry.options)) + self.initialize_options(self.config_entry) return self._options @options.setter @@ -3161,7 +3165,7 @@ class OptionsFlowWithConfigEntry(OptionsFlow): "inherits from OptionsFlowWithConfigEntry, which is deprecated " "and will stop working in 2025.12", error_if_integration=False, - error_if_core=False, + error_if_core=True, ) diff --git a/homeassistant/helpers/schema_config_entry_flow.py b/homeassistant/helpers/schema_config_entry_flow.py index 7463c9945b2..58a44f9682d 100644 --- a/homeassistant/helpers/schema_config_entry_flow.py +++ b/homeassistant/helpers/schema_config_entry_flow.py @@ -16,7 +16,6 @@ from homeassistant.config_entries import ( ConfigFlow, ConfigFlowResult, OptionsFlow, - OptionsFlowWithConfigEntry, ) from homeassistant.core import HomeAssistant, callback, split_entity_id from homeassistant.data_entry_flow import UnknownHandler @@ -403,7 +402,7 @@ class SchemaConfigFlowHandler(ConfigFlow, ABC): ) -class SchemaOptionsFlowHandler(OptionsFlowWithConfigEntry): +class SchemaOptionsFlowHandler(OptionsFlow): """Handle a schema based options flow.""" def __init__( @@ -422,10 +421,8 @@ class SchemaOptionsFlowHandler(OptionsFlowWithConfigEntry): options, which is the union of stored options and user input from the options flow steps. """ - super().__init__(config_entry) - self._common_handler = SchemaCommonFlowHandler( - self, options_flow, self._options - ) + self.initialize_options(config_entry) + self._common_handler = SchemaCommonFlowHandler(self, options_flow, self.options) self._async_options_flow_finished = async_options_flow_finished for step in options_flow: