22
33from __future__ import annotations
44
5+ from copy import deepcopy
56from typing import Any , Self
67
78from plugwise import Smile
2223 ConfigFlow ,
2324 ConfigFlowResult ,
2425 OptionsFlow ,
25- OptionsFlowWithConfigEntry ,
2626)
2727
2828# Upstream
@@ -247,35 +247,39 @@ async def async_step_user(
247247 @callback
248248 def async_get_options_flow (
249249 config_entry : PlugwiseConfigEntry ,
250- ) -> OptionsFlow : # pw-beta options
250+ ) -> PlugwiseOptionsFlowHandler : # pw-beta options
251251 """Get the options flow for this handler."""
252252 return PlugwiseOptionsFlowHandler (config_entry )
253253
254254
255255# pw-beta - change the scan-interval via CONFIGURE
256256# pw-beta - add homekit emulation via CONFIGURE
257257# pw-beta - change the frontend refresh interval via CONFIGURE
258- class PlugwiseOptionsFlowHandler (OptionsFlowWithConfigEntry ): # pw-beta options
258+ class PlugwiseOptionsFlowHandler (OptionsFlow ): # pw-beta options
259259 """Plugwise option flow."""
260260
261+ def __init__ (self , config_entry : ConfigEntry ) -> None :
262+ """Initialize options flow."""
263+ self .options = deepcopy (dict (config_entry .options ))
264+
261265 def _create_options_schema (self , coordinator : PlugwiseDataUpdateCoordinator ) -> vol .Schema :
262266 interval = DEFAULT_SCAN_INTERVAL [coordinator .api .smile_type ] # pw-beta options
263267 schema = {
264268 vol .Optional (
265269 CONF_SCAN_INTERVAL ,
266- default = self ._options .get (CONF_SCAN_INTERVAL , interval .seconds ),
270+ default = self .options .get (CONF_SCAN_INTERVAL , interval .seconds ),
267271 ): vol .All (cv .positive_int , vol .Clamp (min = 10 )),
268272 } # pw-beta
269273
270274 if coordinator .api .smile_type == THERMOSTAT :
271275 schema .update ({
272276 vol .Optional (
273277 CONF_HOMEKIT_EMULATION ,
274- default = self ._options .get (CONF_HOMEKIT_EMULATION , False ),
278+ default = self .options .get (CONF_HOMEKIT_EMULATION , False ),
275279 ): vol .All (cv .boolean ),
276280 vol .Optional (
277281 CONF_REFRESH_INTERVAL ,
278- default = self ._options .get (CONF_REFRESH_INTERVAL , 1.5 ),
282+ default = self .options .get (CONF_REFRESH_INTERVAL , 1.5 ),
279283 ): vol .All (vol .Coerce (float ), vol .Range (min = 1.5 , max = 10.0 )),
280284 }) # pw-beta
281285
@@ -287,7 +291,7 @@ async def async_step_none(
287291 """No options available."""
288292 if user_input is not None :
289293 # Apparently not possible to abort an options flow at the moment
290- return self .async_create_entry (title = "" , data = self ._options )
294+ return self .async_create_entry (title = "" , data = self .options )
291295 return self .async_show_form (step_id = "none" )
292296
293297 async def async_step_init (self , user_input : dict [str , Any ] | None = None ) -> ConfigFlowResult :
0 commit comments