Skip to content

Commit c2e4ffd

Browse files
committed
Improve support for groups
1 parent b13f7da commit c2e4ffd

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

plugwise/common.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from plugwise.constants import (
1111
ANNA,
12+
GROUP_TYPES,
1213
NONE,
1314
PRIORITY_DEVICE_CLASSES,
1415
SPECIAL_PLUG_TYPES,
@@ -187,15 +188,15 @@ def _entity_switching_group(self, entity: GwEntityData, data: GwEntityData) -> N
187188
data["switches"]["relay"] = counter != 0
188189
self._count += 1
189190

190-
def _get_group_switches(self) -> dict[str, GwEntityData]:
191+
def _get_groups(self) -> dict[str, GwEntityData]:
191192
"""Helper-function for smile.py: get_all_gateway_entities().
192193
193194
Collect switching- or pump-group info.
194195
"""
195-
switch_groups: dict[str, GwEntityData] = {}
196-
# P1 and Anna don't have switchgroups
196+
groups: dict[str, GwEntityData] = {}
197+
# P1 and Anna don't have groups
197198
if self.smile.type == "power" or self.check_name(ANNA):
198-
return switch_groups
199+
return groups
199200

200201
for group in self._domain_objects.findall("./group"):
201202
members: list[str] = []
@@ -208,17 +209,17 @@ def _get_group_switches(self) -> dict[str, GwEntityData]:
208209
if item.attrib["id"] in self.gw_entities:
209210
members.append(item.attrib["id"])
210211

211-
if group_type in SWITCH_GROUP_TYPES and members:
212-
switch_groups[group_id] = {
212+
if group_type in GROUP_TYPES and members:
213+
groups[group_id] = {
213214
"dev_class": group_type,
214-
"model": "Switchgroup",
215+
"model": "Group",
215216
"name": group_name,
216217
"members": members,
217218
"vendor": "Plugwise",
218219
}
219220
self._count += 5
220221

221-
return switch_groups
222+
return groups
222223

223224
def _get_lock_state(
224225
self, xml: etree.Element, data: GwEntityData, stretch_v2: bool = False

plugwise/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@
299299
]
300300
BINARY_SENSORS: Final[tuple[str, ...]] = get_args(BinarySensorType)
301301

302+
GROUP_TYPES: Final[tuple[str, ...]] = ("pumping", "report", "switching")
303+
302304
SensorType = Literal[
303305
"battery",
304306
"cooling_activation_outdoor_temperature",

plugwise/legacy/smile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get_all_gateway_entities(self) -> None:
8282
Finally, collect the data and states for each entity.
8383
"""
8484
self._all_appliances()
85-
if group_data := self._get_group_switches():
85+
if group_data := self._get_groups():
8686
self.gw_entities.update(group_data)
8787

8888
self._all_entity_data()

plugwise/smile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def get_all_gateway_entities(self) -> None:
115115
if self.check_name(ADAM):
116116
self._scan_thermostats()
117117

118-
if group_data := self._get_group_switches():
118+
if group_data := self._get_groups():
119119
self.gw_entities.update(group_data)
120120

121121
self._all_entity_data()

0 commit comments

Comments
 (0)