Skip to content

Commit 2c57dc2

Browse files
authored
Merge pull request #457 from plugwise/cooling_ena_fail
Add detection&removal of orphaned heater_central
2 parents f9a48d6 + 132d11d commit 2c57dc2

File tree

4 files changed

+107
-19
lines changed

4 files changed

+107
-19
lines changed

CHANGELOG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# Changelog
22

3-
## Ongoing
3+
## v0.35.2
44

5-
- Typing-constants clean-up
6-
- Improve/optimize/reorder
5+
- Add detection & removal of orphaned heater_central.
6+
- Bugfix for [Core Issue #104433](https://github.com/home-assistant/core/issues/104433)
7+
- Improve/optimize/reorder.
8+
- Typing-constants clean-up.
79

810
## v0.35.1
911

10-
- Update OFF-constant, removal capital begin-letter
12+
- Update OFF-constant, removal capital begin-letter.
1113

1214
## v0.35.0
1315

plugwise/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ class DeviceData(TypedDict, total=False):
488488
"""The Device Data class, covering the collected and ordered output-data per device."""
489489

490490
# Appliance base data
491+
has_actuators: bool
491492
dev_class: str
492493
firmware: str | None
493494
hardware: str

plugwise/helper.py

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -570,15 +570,21 @@ def _all_appliances(self) -> None:
570570
# Legacy P1 has no more devices
571571
return
572572

573+
hc_count = 0
573574
for appliance in self._appliances.findall("./appliance"):
574575
appl = Munch()
575576
appl.pwclass = appliance.find("type").text
576-
# Skip thermostats that have this key, should be an orphaned device (Core #81712)
577+
# Count amount of heater_central's
578+
if appl.pwclass == "heater_central":
579+
hc_count += 1
580+
# Mark heater_central and thermostat that don't have actuator_functionalities,
581+
# could be an orphaned device (Core #81712, #104433)
582+
appl.has_actuators = True
577583
if (
578-
appl.pwclass == "thermostat"
584+
appl.pwclass in ["heater_central", "thermostat"]
579585
and appliance.find("actuator_functionalities/") is None
580586
):
581-
continue
587+
appl.has_actuators = False
582588

583589
appl.location = None
584590
if (appl_loc := appliance.find("location")) is not None:
@@ -622,6 +628,7 @@ def _all_appliances(self) -> None:
622628
for key, value in {
623629
"firmware": appl.firmware,
624630
"hardware": appl.hardware,
631+
"has_actuators": appl.has_actuators,
625632
"location": appl.location,
626633
"mac_address": appl.mac,
627634
"model": appl.model,
@@ -634,6 +641,22 @@ def _all_appliances(self) -> None:
634641
self.gw_devices[appl.dev_id][appl_key] = value
635642
self._count += 1
636643

644+
# Remove thermostat with empty actuator_functionalities (Core #81712), remove heater_central
645+
# with empty actuator_functionalities but only when there are more than one (Core #104433).
646+
for dev_id, device in dict(self.gw_devices).items():
647+
if device["dev_class"] == "thermostat" or (
648+
device["dev_class"] == "heater_central" and hc_count > 1
649+
):
650+
if not self.gw_devices[dev_id]["has_actuators"]:
651+
self._count -= len(self.gw_devices[dev_id])
652+
self.gw_devices.pop(dev_id)
653+
else:
654+
self.gw_devices[dev_id].pop("has_actuators")
655+
self._count -= 1
656+
elif "has_actuators" in self.gw_devices[dev_id]:
657+
self.gw_devices[dev_id].pop("has_actuators")
658+
self._count -= 1
659+
637660
# For non-legacy P1 collect the connected SmartMeter info
638661
if self.smile_type == "power":
639662
self._p1_smartmeter_info_finder(appl)
@@ -1521,15 +1544,12 @@ def _get_toggle_state(
15211544
Obtain the toggle state of a 'toggle' = switch.
15221545
"""
15231546
if xml.find("type").text == "heater_central":
1524-
locator = "./actuator_functionalities/toggle_functionality"
1525-
if found := xml.findall(locator):
1526-
for item in found:
1527-
if (toggle_type := item.find("type")) is not None:
1528-
if toggle_type.text == toggle:
1529-
data["switches"][name] = item.find("state").text == "on"
1530-
self._count += 1
1531-
# Remove the cooling_enabled binary_sensor when the corresponding switch is present
1532-
# Except for Elga
1533-
if toggle == "cooling_enabled" and not self._elga:
1534-
data["binary_sensors"].pop("cooling_enabled")
1535-
self._count -= 1
1547+
locator = f"./actuator_functionalities/toggle_functionality[type='{toggle}']/state"
1548+
if (state := xml.find(locator)) is not None:
1549+
data["switches"][name] = state.text == "on"
1550+
self._count += 1
1551+
# Remove the cooling_enabled binary_sensor when the corresponding switch is present
1552+
# Except for Elga
1553+
if toggle == "cooling_enabled" and not self._elga:
1554+
data["binary_sensors"].pop("cooling_enabled")
1555+
self._count -= 1

userdata/anna_loria_cooling_active/core.appliances.xml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,71 @@
245245
</offset_functionality>
246246
</actuator_functionalities>
247247
</appliance>
248+
<appliance id='7eedf0882c76441894f0c6e6d4e2e0b1'>
249+
<name>Central heating boiler</name>
250+
<description></description>
251+
<type>heater_central</type>
252+
<created_date>2020-09-04T16:00:31.445+02:00</created_date>
253+
<modified_date>2023-04-24T22:10:45.198+02:00</modified_date>
254+
<deleted_date></deleted_date>
255+
<groups/>
256+
<logs>
257+
<point_log id='06d5ac3dab7a496994b9e86aaed5f327'>
258+
<type>burner_efficiency</type>
259+
<unit>s</unit>
260+
<updated_date></updated_date>
261+
<last_consecutive_log_date></last_consecutive_log_date>
262+
<interval/>
263+
</point_log>
264+
<point_log id='5af30fdb36644525a54a09e11a37c93c'>
265+
<type>central_heating_state</type>
266+
<unit></unit>
267+
<updated_date>2020-10-14T12:01:24.963+02:00</updated_date>
268+
<last_consecutive_log_date>2020-10-14T12:01:24.963+02:00</last_consecutive_log_date>
269+
<interval/>
270+
<period start_date="2020-10-14T12:01:24.963+02:00" end_date="2020-10-14T12:01:24.963+02:00">
271+
<measurement log_date="2020-10-14T12:01:24.963+02:00">off</measurement>
272+
</period>
273+
</point_log>
274+
<point_log id='6bb8ca7751c24ec781b3d5e2d81a685a'>
275+
<type>boiler_temperature</type>
276+
<unit>C</unit>
277+
<updated_date></updated_date>
278+
<last_consecutive_log_date></last_consecutive_log_date>
279+
<interval>PT1H</interval>
280+
<thermo_meter id='731ea93df60a40fba8fb01e2a240a98a'/>
281+
</point_log>
282+
<interval_log id='728a0285b9574514aa0d37e9d4e29b5a'>
283+
<type>burner_operation_time</type>
284+
<unit>s</unit>
285+
<updated_date>2023-04-24T22:00:00+02:00</updated_date>
286+
<last_consecutive_log_date>2023-04-24T21:00:00+02:00</last_consecutive_log_date>
287+
<interval>PT1H</interval>
288+
<interval_chrono_meter id='e243d6ab066749669f1c60560dc761a9'/>
289+
<period start_date="2023-04-24T22:00:00+02:00" end_date="2023-04-24T22:00:00+02:00" interval="PT1H">
290+
<measurement log_date="2023-04-24T22:00:00+02:00">0</measurement>
291+
</period>
292+
</interval_log>
293+
<interval_log id='c3dab94782644d2e82827b2a85c01dd0'>
294+
<type>burner_efficiency</type>
295+
<unit>s</unit>
296+
<updated_date></updated_date>
297+
<last_consecutive_log_date></last_consecutive_log_date>
298+
<interval>PT1H</interval>
299+
</interval_log>
300+
<point_log id='cf65631d2523484b94037b2bb578ab0e'>
301+
<type>intended_central_heating_state</type>
302+
<unit></unit>
303+
<updated_date>2020-10-14T11:57:27.823+02:00</updated_date>
304+
<last_consecutive_log_date>2020-10-14T11:57:27.823+02:00</last_consecutive_log_date>
305+
<interval/>
306+
<period start_date="2020-10-14T11:57:27.823+02:00" end_date="2020-10-14T11:57:27.823+02:00">
307+
<measurement log_date="2020-10-14T11:57:27.823+02:00">off</measurement>
308+
</period>
309+
</point_log>
310+
</logs>
311+
<actuator_functionalities/>
312+
</appliance>
248313
<appliance id='bfb5ee0a88e14e5f97bfa725a760cc49'>
249314
<name>Central heating boiler</name>
250315
<description></description>

0 commit comments

Comments
 (0)