@@ -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 ]] = []
85+ heater_central_count = 0
86+ heater_central_list : list [dict [str , bool ]] = []
8787 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- )
88+ if not heater_central :
89+ continue # pragma: no cover
90+
91+ heater_central_count += 1
92+ if (heater_central_id := heater_central .get ("id" )) is None :
93+ continue # pragma: no cover
94+
95+ has_actuators = heater_central .find ("actuator_functionalities/" ) is not None
9396 # 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 })
97+ if (heater_central_name := heater_central .find ("name" )) is None :
98+ continue # pragma: no cover
99+
100+ if heater_central_name .text == "Central heating boiler" :
101+ heater_central_list .append ({heater_central_id : has_actuators })
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