@@ -190,22 +190,23 @@ async def _smile_detect(
190190 """
191191 model : str = "Unknown"
192192 if (gateway := result .find ("./gateway" )) is not None :
193- if (vendor_model := gateway .find ("vendor_model" )) is not None :
194- model = vendor_model .text
195- elec_measurement = gateway .find (
196- "gateway_environment/electricity_consumption_tariff_structure"
197- )
198- if (
199- elec_measurement is not None
200- and elec_measurement .text
201- and model == "smile_thermo"
202- ):
203- self .smile .anna_p1 = True
204-
205193 self .smile .version = parse (gateway .find ("firmware_version" ).text )
206194 self .smile .hw_version = gateway .find ("hardware_version" ).text
207195 self .smile .hostname = gateway .find ("hostname" ).text
208196 self .smile .mac_address = gateway .find ("mac_address" ).text
197+ if (vendor_model := gateway .find ("vendor_model" )) is None :
198+ return
199+
200+ model = vendor_model .text
201+ elec_measurement = gateway .find (
202+ "gateway_environment/electricity_consumption_tariff_structure"
203+ )
204+ if (
205+ elec_measurement is not None
206+ and elec_measurement .text
207+ and model == "smile_thermo"
208+ ):
209+ self .smile .anna_p1 = True
209210 else :
210211 model = await self ._smile_detect_legacy (result , dsmrmain , model )
211212
@@ -250,23 +251,29 @@ async def _smile_detect(
250251 if self .smile .type == "stretch" :
251252 self ._stretch_v2 = int (version_major ) == 2
252253
253- if self .smile .type == "thermostat" :
254- self ._is_thermostat = True
255- # For Adam, Anna, determine the system capabilities:
256- # Find the connected heating/cooling device (heater_central),
257- # e.g. heat-pump or gas-fired heater
258- onoff_boiler = result .find ("./module/protocols/onoff_boiler" )
259- open_therm_boiler = result .find ("./module/protocols/open_therm_boiler" )
260- self ._on_off_device = onoff_boiler is not None
261- self ._opentherm_device = open_therm_boiler is not None
262-
263- # Determine the presence of special features
264- locator_1 = "./gateway/features/cooling"
265- locator_2 = "./gateway/features/elga_support"
266- if result .find (locator_1 ) is not None :
267- self ._cooling_present = True
268- if result .find (locator_2 ) is not None :
269- self ._elga = True
254+ self ._process_for_thermostat (result )
255+
256+ def _process_for_thermostat (self , result : etree .Element ) -> None :
257+ """Extra processing for thermostats."""
258+ if self .smile .type != "thermostat" :
259+ return
260+
261+ self ._is_thermostat = True
262+ # For Adam, Anna, determine the system capabilities:
263+ # Find the connected heating/cooling device (heater_central),
264+ # e.g. heat-pump or gas-fired heater
265+ onoff_boiler = result .find ("./module/protocols/onoff_boiler" )
266+ open_therm_boiler = result .find ("./module/protocols/open_therm_boiler" )
267+ self ._on_off_device = onoff_boiler is not None
268+ self ._opentherm_device = open_therm_boiler is not None
269+
270+ # Determine the presence of special features
271+ locator_1 = "./gateway/features/cooling"
272+ locator_2 = "./gateway/features/elga_support"
273+ if result .find (locator_1 ) is not None :
274+ self ._cooling_present = True
275+ if result .find (locator_2 ) is not None :
276+ self ._elga = True
270277
271278 async def _smile_detect_legacy (
272279 self , result : etree .Element , dsmrmain : etree .Element , model : str
0 commit comments