From 974467cf038d11746fe30be43745a3ff77126a64 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:28:16 +0100 Subject: [PATCH] Drop usage of OptionsFlowWithConfigEntry Based https://github.com/home-assistant/developers.home-assistant/pull/2435 --- custom_components/poolmath/config_flow.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/custom_components/poolmath/config_flow.py b/custom_components/poolmath/config_flow.py index 104d665..e534657 100644 --- a/custom_components/poolmath/config_flow.py +++ b/custom_components/poolmath/config_flow.py @@ -8,9 +8,9 @@ from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, - OptionsFlowWithConfigEntry, + OptionsFlow, ) -from homeassistant.const import CONF_NAME +from homeassistant.const import CONF_NAME, __version__ as HAVERSION from homeassistant.core import callback from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers import config_validation as cv @@ -29,7 +29,7 @@ LOG = logging.getLogger(__name__) -def _initial_form(flow: Union[ConfigFlow, OptionsFlowWithConfigEntry]): +def _initial_form(flow: Union[ConfigFlow, OptionsFlow]): """Return flow form for init/user step id.""" if isinstance(flow, ConfigFlow): @@ -38,7 +38,7 @@ def _initial_form(flow: Union[ConfigFlow, OptionsFlowWithConfigEntry]): name = DEFAULT_NAME timeout = DEFAULT_TIMEOUT target = DEFAULT_TARGET - elif isinstance(flow, OptionsFlowWithConfigEntry): + elif isinstance(flow, OptionsFlow): step_id = "init" share_id = flow.config_entry.options.get(CONF_SHARE_ID) name = flow.config_entry.options.get(CONF_NAME, DEFAULT_NAME) @@ -65,9 +65,14 @@ def _initial_form(flow: Union[ConfigFlow, OptionsFlowWithConfigEntry]): ) -class PoolMathOptionsFlow(OptionsFlowWithConfigEntry): +class PoolMathOptionsFlow(OptionsFlow): """Handle Pool Math options.""" + def __init__(self, config_entry: ConfigEntry) -> None: + """Initialize options flow.""" + if AwesomeVersion(HAVERSION) < "2024.11.99": + self.config_entry = config_entry + async def async_step_init( self, user_input: dict[str, Any] | None = None ) -> FlowResult: