Skip to content

Commit 410bcea

Browse files
committed
Fix counting in _appliance_measurements()
1 parent d1dc988 commit 410bcea

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

plugwise/helper.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -601,14 +601,15 @@ def _appliance_measurements(
601601
appl_i_loc.text, ENERGY_WATT_HOUR
602602
)
603603

604-
if data.get("binary_sensors"):
605-
self._count += len(data["binary_sensors"])
606-
if data.get("sensors"):
607-
self._count += len(data["sensors"])
608-
if data.get("switches"):
609-
self._count += len(data["switches"])
610-
# Don't count the above top-level dicts, only the remaining single items
611-
self._count += len(data) - 3
604+
# Don't count the below top-level dicts when present
605+
if "binary_sensors" in data:
606+
self._count += len(data["binary_sensors"]) -1
607+
if "sensors" in data:
608+
self._count += len(data["sensors"]) - 1
609+
if "switches" in data:
610+
self._count += len(data["switches"]) -1
611+
# Count the remaining single data items,
612+
self._count += len(data)
612613

613614
def _get_toggle_state(
614615
self, xml: etree, toggle: str, name: ToggleNameType, data: GwEntityData

0 commit comments

Comments
 (0)