|
46 | 46 | SwitchType, |
47 | 47 | ThermoLoc, |
48 | 48 | ) |
49 | | -from plugwise.util import format_measure, power_data_local_format, version_to_model |
| 49 | +from plugwise.util import ( |
| 50 | + check_heater_central, |
| 51 | + format_measure, |
| 52 | + power_data_local_format, |
| 53 | + version_to_model, |
| 54 | +) |
50 | 55 |
|
51 | 56 | # This way of importing aiohttp is because of patch/mocking in testing (aiohttp timeouts) |
52 | 57 | from defusedxml import ElementTree as etree |
@@ -218,7 +223,7 @@ def _appliance_info_finder(self, appliance: etree, appl: Munch) -> Munch: |
218 | 223 | return None |
219 | 224 |
|
220 | 225 | # Find the valid heater_central |
221 | | - self._heater_id = self._check_heater_central() |
| 226 | + self._heater_id = check_heater_central(self._appliances) |
222 | 227 |
|
223 | 228 | # Info for On-Off device |
224 | 229 | if self._on_off_device: |
@@ -248,34 +253,6 @@ def _appliance_info_finder(self, appliance: etree, appl: Munch) -> Munch: |
248 | 253 |
|
249 | 254 | return appl |
250 | 255 |
|
251 | | - def _check_heater_central(self) -> str: |
252 | | - """Find the valid heater_central, helper-function for _appliance_info_finder(). |
253 | | -
|
254 | | - Solution for Core Issue #104433, |
255 | | - for a system that has two heater_central appliances. |
256 | | - """ |
257 | | - locator = "./appliance[type='heater_central']" |
258 | | - hc_count = 0 |
259 | | - hc_list: list[dict[str, bool]] = [] |
260 | | - for heater_central in self._appliances.findall(locator): |
261 | | - hc_count += 1 |
262 | | - hc_id: str = heater_central.attrib["id"] |
263 | | - has_actuators: bool = ( |
264 | | - heater_central.find("actuator_functionalities/") is not None |
265 | | - ) |
266 | | - hc_list.append({hc_id: has_actuators}) |
267 | | - |
268 | | - heater_central_id = list(hc_list[0].keys())[0] |
269 | | - if hc_count > 1: |
270 | | - for item in hc_list: # pragma: no cover |
271 | | - for key, value in item.items(): # pragma: no cover |
272 | | - if value: # pragma: no cover |
273 | | - heater_central_id = key # pragma: no cover |
274 | | - # Stop when a valid id is found |
275 | | - break # pragma: no cover |
276 | | - |
277 | | - return heater_central_id |
278 | | - |
279 | 256 | def _p1_smartmeter_info_finder(self, appl: Munch) -> None: |
280 | 257 | """Collect P1 DSMR Smartmeter info.""" |
281 | 258 | loc_id = next(iter(self.loc_data.keys())) |
|
0 commit comments