@@ -82,30 +82,36 @@ def check_heater_central(xml: etree.Element) -> str:
8282 for a system that has two heater_central appliances.
8383 """
8484 locator = "./appliance[type='heater_central']"
85- hc_count = 0
86- hc_list : list [dict [str , bool ]] = []
87- for heater_central in xml .findall (locator ):
88- hc_count += 1
89- hc_id : str = heater_central .get ("id" )
90- has_actuators : bool = (
91- heater_central .find ("actuator_functionalities/" ) is not None
92- )
85+ heater_central_count = 0
86+ heater_central_list : list [dict [str , bool ]] = []
87+ if not (result := xml .findall (locator )):
88+ return NONE # pragma: no cover
89+
90+ for heater_central in result :
91+ if (heater_central_id := heater_central .get ("id" )) is None :
92+ continue # pragma: no cover
93+
94+ if (heater_central_name := heater_central .find ("name" )) is None :
95+ continue # pragma: no cover
96+
97+ has_actuators = heater_central .find ("actuator_functionalities/" ) is not None
9398 # Filter for Plug/Circle/Stealth heater_central -- Pw-Beta Issue #739
94- if heater_central .find ("name" ).text == "Central heating boiler" :
95- hc_list .append ({hc_id : has_actuators })
99+ if heater_central_name .text == "Central heating boiler" :
100+ heater_central_list .append ({heater_central_id : has_actuators })
101+ heater_central_count += 1
96102
97- if not hc_list :
103+ if not heater_central_list :
98104 return NONE # pragma: no cover
99105
100- heater_central_id = list (hc_list [0 ].keys ())[0 ]
101- if hc_count > 1 :
102- for item in hc_list :
103- hc_id , has_actuators = next (iter (item .items ()))
106+ heater_id = list (heater_central_list [0 ].keys ())[0 ]
107+ if heater_central_count > 1 :
108+ for item in heater_central_list :
109+ heater_central_id , has_actuators = next (iter (item .items ()))
104110 if has_actuators :
105- heater_central_id = hc_id
111+ heater_id = heater_central_id
106112 break
107113
108- return heater_central_id
114+ return heater_id
109115
110116
111117def check_model (name : str | None , vendor_name : str | None ) -> str | None :
0 commit comments