3535 CONF_PASSWORD ,
3636 CONF_PORT ,
3737 CONF_SCAN_INTERVAL ,
38+ CONF_TIMEOUT ,
3839 CONF_USERNAME ,
3940)
4041
5051 CONTEXT ,
5152 DEFAULT_PORT ,
5253 DEFAULT_SCAN_INTERVAL , # pw-beta option
54+ DEFAULT_TIMEOUT ,
5355 DEFAULT_USERNAME ,
5456 DOMAIN ,
5557 FLOW_ID ,
7072
7173# Upstream
7274from .coordinator import PlugwiseDataUpdateCoordinator
75+ from .util import get_timeout_for_version
7376
7477type PlugwiseConfigEntry = ConfigEntry [PlugwiseDataUpdateCoordinator ]
7578
@@ -103,7 +106,6 @@ def _base_schema(
103106 ),
104107 }
105108 )
106-
107109 return vol .Schema ({vol .Required (CONF_PASSWORD ): str })
108110
109111
@@ -118,7 +120,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> Smile:
118120 password = data [CONF_PASSWORD ],
119121 port = data [CONF_PORT ],
120122 username = data [CONF_USERNAME ],
121- timeout = 30 ,
123+ timeout = data [ CONF_TIMEOUT ] ,
122124 websession = websession ,
123125 )
124126 await api .connect ()
@@ -129,9 +131,11 @@ class PlugwiseConfigFlow(ConfigFlow, domain=DOMAIN):
129131 """Handle a config flow for Plugwise Smile."""
130132
131133 VERSION = 1
134+ MINOR_VERSION = 2
132135
133136 discovery_info : ZeroconfServiceInfo | None = None
134137 _username : str = DEFAULT_USERNAME
138+ _timeout : int = DEFAULT_TIMEOUT
135139
136140 async def async_step_zeroconf (
137141 self , discovery_info : ZeroconfServiceInfo
@@ -147,9 +151,10 @@ async def async_step_zeroconf(
147151 self .hass ,
148152 {
149153 CONF_HOST : discovery_info .host ,
154+ CONF_PASSWORD : config_entry .data [CONF_PASSWORD ],
150155 CONF_PORT : discovery_info .port ,
151156 CONF_USERNAME : config_entry .data [CONF_USERNAME ],
152- CONF_PASSWORD : config_entry . data [ CONF_PASSWORD ] ,
157+ CONF_TIMEOUT : self . _timeout ,
153158 },
154159 )
155160 except Exception : # noqa: BLE001
@@ -168,6 +173,8 @@ async def async_step_zeroconf(
168173 _version = _properties .get (VERSION , "n/a" )
169174 _name = f"{ ZEROCONF_MAP .get (_product , _product )} v{ _version } "
170175
176+ self ._timeout = get_timeout_for_version (_version )
177+
171178 # This is an Anna, but we already have config entries.
172179 # Assuming that the user has already configured Adam, aborting discovery.
173180 if self ._async_current_entries () and _product == SMILE_THERMO :
@@ -200,6 +207,7 @@ async def async_step_zeroconf(
200207 CONF_HOST : discovery_info .host ,
201208 CONF_NAME : _name ,
202209 CONF_PORT : discovery_info .port ,
210+ CONF_TIMEOUT : self ._timeout ,
203211 CONF_USERNAME : self ._username ,
204212 },
205213 ATTR_CONFIGURATION_URL : (
@@ -227,6 +235,8 @@ async def async_step_user(
227235 user_input [CONF_HOST ] = self .discovery_info .host
228236 user_input [CONF_PORT ] = self .discovery_info .port
229237 user_input [CONF_USERNAME ] = self ._username
238+
239+ user_input [CONF_TIMEOUT ] = self ._timeout
230240 try :
231241 api = await validate_input (self .hass , user_input )
232242 except ConnectionFailedError :
@@ -253,7 +263,6 @@ async def async_step_user(
253263 api .smile_hostname or api .gateway_id , raise_on_progress = False
254264 )
255265 self ._abort_if_unique_id_configured ()
256-
257266 return self .async_create_entry (title = api .smile_name , data = user_input )
258267
259268 @staticmethod
@@ -278,7 +287,6 @@ async def async_step_none(
278287 if user_input is not None :
279288 # Apparently not possible to abort an options flow at the moment
280289 return self .async_create_entry (title = "" , data = self ._options )
281-
282290 return self .async_show_form (step_id = "none" )
283291
284292 async def async_step_init (
@@ -322,5 +330,4 @@ async def async_step_init(
322330 ): vol .All (vol .Coerce (float ), vol .Range (min = 1.5 , max = 10.0 )),
323331 }
324332 ) # pw-beta
325-
326333 return self .async_show_form (step_id = INIT , data_schema = vol .Schema (data ))
0 commit comments