@@ -187,7 +187,14 @@ async def _smile_detect(
187187 """Helper-function for connect().
188188
189189 Detect which type of Plugwise Gateway is being connected.
190+ Store the collected data, also collect some specific thermostat devices.
190191 """
192+ model = await self ._collect_smile_data (dsmrmain , result )
193+ self ._store_smile_data (model )
194+ self ._process_for_thermostat (result )
195+
196+ async def _collect_smile_data (self , dsmrmain : etree .Element , result : etree .Element ) -> str :
197+ """Collect smile/gateway data."""
191198 model : str = "Unknown"
192199 if (gateway := result .find ("./gateway" )) is not None :
193200 self .smile .version = parse (gateway .find ("firmware_version" ).text )
@@ -218,6 +225,35 @@ async def _smile_detect(
218225 )
219226 raise UnsupportedDeviceError
220227
228+ return model
229+
230+ def _process_for_thermostat (self , result : etree .Element ) -> None :
231+ """Extra processing for thermostats."""
232+ if self .smile .type != "thermostat" :
233+ return
234+
235+ self ._is_thermostat = True
236+ # For Adam, Anna, determine the system capabilities:
237+ # Find the connected heating/cooling device (heater_central),
238+ # e.g. heat-pump or gas-fired heater
239+ onoff_boiler = result .find ("./module/protocols/onoff_boiler" )
240+ open_therm_boiler = result .find ("./module/protocols/open_therm_boiler" )
241+ self ._on_off_device = onoff_boiler is not None
242+ self ._opentherm_device = open_therm_boiler is not None
243+
244+ # Determine the presence of special features
245+ locator_1 = "./gateway/features/cooling"
246+ locator_2 = "./gateway/features/elga_support"
247+ if result .find (locator_1 ) is not None :
248+ self ._cooling_present = True
249+ if result .find (locator_2 ) is not None :
250+ self ._elga = True
251+
252+ def _store_smile_data (self , model : str ) -> None :
253+ """Store the collected the smile/gateway data.
254+
255+ Perform some checks, and set a shorter timeout for non-legacy Gateways.
256+ """
221257 version_major = str (self .smile .version .major )
222258 self ._target_smile = f"{ model } _v{ version_major } "
223259 LOGGER .debug ("Plugwise identified as %s" , self ._target_smile )
@@ -249,30 +285,6 @@ async def _smile_detect(
249285 if self .smile .type == "stretch" :
250286 self ._stretch_v2 = int (version_major ) == 2
251287
252- self ._process_for_thermostat (result )
253-
254- def _process_for_thermostat (self , result : etree .Element ) -> None :
255- """Extra processing for thermostats."""
256- if self .smile .type != "thermostat" :
257- return
258-
259- self ._is_thermostat = True
260- # For Adam, Anna, determine the system capabilities:
261- # Find the connected heating/cooling device (heater_central),
262- # e.g. heat-pump or gas-fired heater
263- onoff_boiler = result .find ("./module/protocols/onoff_boiler" )
264- open_therm_boiler = result .find ("./module/protocols/open_therm_boiler" )
265- self ._on_off_device = onoff_boiler is not None
266- self ._opentherm_device = open_therm_boiler is not None
267-
268- # Determine the presence of special features
269- locator_1 = "./gateway/features/cooling"
270- locator_2 = "./gateway/features/elga_support"
271- if result .find (locator_1 ) is not None :
272- self ._cooling_present = True
273- if result .find (locator_2 ) is not None :
274- self ._elga = True
275-
276288 async def _smile_detect_legacy (
277289 self , result : etree .Element , dsmrmain : etree .Element , model : str
278290 ) -> str :
0 commit comments