Skip to content

Commit 8e04b65

Browse files
authored
Merge pull request #981 from plugwise/disable-switch-groups-2
Remove Plugwise switch-groups - use HA group-helper to create switch-groups instead
2 parents 3817e52 + 8bce8e6 commit 8e04b65

File tree

9 files changed

+20
-289
lines changed

9 files changed

+20
-289
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
Versions from 0.40 and up
44

5-
## Ongoing
5+
## v0.62.0
66

77
- Improve automatic deletion of device(s) removed from the backend output, via PR [$982](https://github.com/plugwise/plugwise-beta/pull/982)
8+
- Block Plugwise switch-groups, use HA group-helper instead, via PR [#981](https://github.com/plugwise/plugwise-beta/pull/981)
89
- Extended feature: extent/improve Plugwise groups, via PR[#976](https://github.com/plugwise/plugwise-beta/pull/976) and plugwise [v1.11.0](https://github.com/plugwise/python-plugwise/releases/tag/v1.11.0)
910
- DeviceInfo: show configuration_url on gateway only, via PR [#975](https://github.com/plugwise/plugwise-beta/pull/975)
1011

custom_components/plugwise/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
SMILE: Final = "smile"
2525
STRETCH: Final = "stretch"
2626
STRETCH_USERNAME: Final = "stretch"
27+
SWITCH_GROUPS: Final[tuple[str, str]] = ("report", "switching")
2728
UNIQUE_IDS: Final = "unique_ids"
2829
ZIGBEE_MAC_ADDRESS: Final = "zigbee_mac_address"
2930

custom_components/plugwise/coordinator.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
3030
from packaging.version import Version
3131

32-
from .const import DEFAULT_SCAN_INTERVAL, DOMAIN, LOGGER
32+
from .const import DEFAULT_SCAN_INTERVAL, DEV_CLASS, DOMAIN, LOGGER, SWITCH_GROUPS
3333

3434
type PlugwiseConfigEntry = ConfigEntry[PlugwiseDataUpdateCoordinator]
3535

@@ -158,10 +158,15 @@ async def _async_update_data(self) -> dict[str, GwEntityData]:
158158

159159
async def _async_add_remove_devices(self, data: dict[str, GwEntityData]) -> None:
160160
"""Add new Plugwise devices, remove non-existing devices."""
161-
set_of_data = set(data)
162-
# Check for new or removed devices,
161+
# Block switch-groups, use HA group helper instead to create switch-groups
162+
for device_id, device in data.copy().items():
163+
if device.get(DEV_CLASS) in SWITCH_GROUPS:
164+
data.pop(device_id)
165+
166+
# Collect new or removed devices,
163167
# 'new_devices' contains all devices present in 'data' at init ('self._current_devices' is empty)
164-
# this is required for the proper initialization of all the present platform entities.
168+
# this is required for the initialization of the available platform entities.
169+
set_of_data = set(data)
165170
self.new_devices = set_of_data - self._current_devices
166171
current_devices = self._stored_devices if not self._current_devices else self._current_devices
167172
self._current_devices = set_of_data

custom_components/plugwise/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"iot_class": "local_polling",
99
"loggers": ["plugwise"],
1010
"requirements": ["plugwise==1.11.0"],
11-
"version": "0.61.0",
11+
"version": "0.62.0",
1212
"zeroconf": ["_plugwise._tcp.local."]
1313
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "plugwise-beta"
3-
version = "0.61.0"
3+
version = "0.62.0"
44
description = "Plugwise beta custom-component"
55
readme = "README.md"
66
requires-python = ">=3.13"

tests/components/plugwise/snapshots/test_diagnostics.ambr

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -596,23 +596,6 @@
596596
'vendor': 'Plugwise',
597597
'zigbee_mac_address': 'ABCD012345670A11',
598598
}),
599-
'e8ef2a01ed3b4139a53bf749204fe6b4': dict({
600-
'dev_class': 'switching',
601-
'members': list([
602-
'02cf28bfec924855854c544690a609ef',
603-
'4a810418d5394b3f82727340b91ba740',
604-
]),
605-
'model': 'Group',
606-
'name': 'Test',
607-
'sensors': dict({
608-
'electricity_consumed': 14.8,
609-
'electricity_produced': 0.0,
610-
}),
611-
'switches': dict({
612-
'relay': True,
613-
}),
614-
'vendor': 'Plugwise',
615-
}),
616599
'f1fee6043d3642a9b0a65297455f008e': dict({
617600
'available': True,
618601
'binary_sensors': dict({

tests/components/plugwise/snapshots/test_sensor.ambr

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,118 +1216,6 @@
12161216
'state': '37.0',
12171217
})
12181218
# ---
1219-
# name: test_adam_sensor_snapshot[platforms0-False-m_adam_heating][sensor.test_electricity_consumed-entry]
1220-
EntityRegistryEntrySnapshot({
1221-
'aliases': set({
1222-
}),
1223-
'area_id': None,
1224-
'capabilities': dict({
1225-
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
1226-
}),
1227-
'config_entry_id': <ANY>,
1228-
'config_subentry_id': <ANY>,
1229-
'device_class': None,
1230-
'device_id': <ANY>,
1231-
'disabled_by': None,
1232-
'domain': 'sensor',
1233-
'entity_category': None,
1234-
'entity_id': 'sensor.test_electricity_consumed',
1235-
'has_entity_name': True,
1236-
'hidden_by': None,
1237-
'icon': None,
1238-
'id': <ANY>,
1239-
'labels': set({
1240-
}),
1241-
'name': None,
1242-
'options': dict({
1243-
'sensor': dict({
1244-
'suggested_display_precision': 0,
1245-
}),
1246-
}),
1247-
'original_device_class': <SensorDeviceClass.POWER: 'power'>,
1248-
'original_icon': None,
1249-
'original_name': 'Electricity consumed',
1250-
'platform': 'plugwise',
1251-
'previous_unique_id': None,
1252-
'suggested_object_id': None,
1253-
'supported_features': 0,
1254-
'translation_key': 'electricity_consumed',
1255-
'unique_id': 'e8ef2a01ed3b4139a53bf749204fe6b4-electricity_consumed',
1256-
'unit_of_measurement': <UnitOfPower.WATT: 'W'>,
1257-
})
1258-
# ---
1259-
# name: test_adam_sensor_snapshot[platforms0-False-m_adam_heating][sensor.test_electricity_consumed-state]
1260-
StateSnapshot({
1261-
'attributes': ReadOnlyDict({
1262-
'device_class': 'power',
1263-
'friendly_name': 'Test Electricity consumed',
1264-
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
1265-
'unit_of_measurement': <UnitOfPower.WATT: 'W'>,
1266-
}),
1267-
'context': <ANY>,
1268-
'entity_id': 'sensor.test_electricity_consumed',
1269-
'last_changed': <ANY>,
1270-
'last_reported': <ANY>,
1271-
'last_updated': <ANY>,
1272-
'state': '16.5',
1273-
})
1274-
# ---
1275-
# name: test_adam_sensor_snapshot[platforms0-False-m_adam_heating][sensor.test_electricity_produced-entry]
1276-
EntityRegistryEntrySnapshot({
1277-
'aliases': set({
1278-
}),
1279-
'area_id': None,
1280-
'capabilities': dict({
1281-
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
1282-
}),
1283-
'config_entry_id': <ANY>,
1284-
'config_subentry_id': <ANY>,
1285-
'device_class': None,
1286-
'device_id': <ANY>,
1287-
'disabled_by': None,
1288-
'domain': 'sensor',
1289-
'entity_category': None,
1290-
'entity_id': 'sensor.test_electricity_produced',
1291-
'has_entity_name': True,
1292-
'hidden_by': None,
1293-
'icon': None,
1294-
'id': <ANY>,
1295-
'labels': set({
1296-
}),
1297-
'name': None,
1298-
'options': dict({
1299-
'sensor': dict({
1300-
'suggested_display_precision': 0,
1301-
}),
1302-
}),
1303-
'original_device_class': <SensorDeviceClass.POWER: 'power'>,
1304-
'original_icon': None,
1305-
'original_name': 'Electricity produced',
1306-
'platform': 'plugwise',
1307-
'previous_unique_id': None,
1308-
'suggested_object_id': None,
1309-
'supported_features': 0,
1310-
'translation_key': 'electricity_produced',
1311-
'unique_id': 'e8ef2a01ed3b4139a53bf749204fe6b4-electricity_produced',
1312-
'unit_of_measurement': <UnitOfPower.WATT: 'W'>,
1313-
})
1314-
# ---
1315-
# name: test_adam_sensor_snapshot[platforms0-False-m_adam_heating][sensor.test_electricity_produced-state]
1316-
StateSnapshot({
1317-
'attributes': ReadOnlyDict({
1318-
'device_class': 'power',
1319-
'friendly_name': 'Test Electricity produced',
1320-
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
1321-
'unit_of_measurement': <UnitOfPower.WATT: 'W'>,
1322-
}),
1323-
'context': <ANY>,
1324-
'entity_id': 'sensor.test_electricity_produced',
1325-
'last_changed': <ANY>,
1326-
'last_reported': <ANY>,
1327-
'last_updated': <ANY>,
1328-
'state': '0.0',
1329-
})
1330-
# ---
13311219
# name: test_adam_sensor_snapshot[platforms0-False-m_adam_heating][sensor.tom_badkamer_battery-entry]
13321220
EntityRegistryEntrySnapshot({
13331221
'aliases': set({

tests/components/plugwise/snapshots/test_switch.ambr

Lines changed: 0 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -440,55 +440,6 @@
440440
'state': 'on',
441441
})
442442
# ---
443-
# name: test_adam_switch_snapshot[platforms0][switch.test_relay-entry]
444-
EntityRegistryEntrySnapshot({
445-
'aliases': set({
446-
}),
447-
'area_id': None,
448-
'capabilities': None,
449-
'config_entry_id': <ANY>,
450-
'config_subentry_id': <ANY>,
451-
'device_class': None,
452-
'device_id': <ANY>,
453-
'disabled_by': None,
454-
'domain': 'switch',
455-
'entity_category': None,
456-
'entity_id': 'switch.test_relay',
457-
'has_entity_name': True,
458-
'hidden_by': None,
459-
'icon': None,
460-
'id': <ANY>,
461-
'labels': set({
462-
}),
463-
'name': None,
464-
'options': dict({
465-
}),
466-
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
467-
'original_icon': None,
468-
'original_name': 'Relay',
469-
'platform': 'plugwise',
470-
'previous_unique_id': None,
471-
'suggested_object_id': None,
472-
'supported_features': 0,
473-
'translation_key': 'relay',
474-
'unique_id': 'e8ef2a01ed3b4139a53bf749204fe6b4-relay',
475-
'unit_of_measurement': None,
476-
})
477-
# ---
478-
# name: test_adam_switch_snapshot[platforms0][switch.test_relay-state]
479-
StateSnapshot({
480-
'attributes': ReadOnlyDict({
481-
'device_class': 'switch',
482-
'friendly_name': 'Test Relay',
483-
}),
484-
'context': <ANY>,
485-
'entity_id': 'switch.test_relay',
486-
'last_changed': <ANY>,
487-
'last_reported': <ANY>,
488-
'last_updated': <ANY>,
489-
'state': 'on',
490-
})
491-
# ---
492443
# name: test_adam_switch_snapshot[platforms0][switch.usg_smart_plug_lock-entry]
493444
EntityRegistryEntrySnapshot({
494445
'aliases': set({
@@ -979,104 +930,6 @@
979930
'state': 'on',
980931
})
981932
# ---
982-
# name: test_stretch_switch_snapshot[platforms0][switch.schakel_relay-entry]
983-
EntityRegistryEntrySnapshot({
984-
'aliases': set({
985-
}),
986-
'area_id': None,
987-
'capabilities': None,
988-
'config_entry_id': <ANY>,
989-
'config_subentry_id': <ANY>,
990-
'device_class': None,
991-
'device_id': <ANY>,
992-
'disabled_by': None,
993-
'domain': 'switch',
994-
'entity_category': None,
995-
'entity_id': 'switch.schakel_relay',
996-
'has_entity_name': True,
997-
'hidden_by': None,
998-
'icon': None,
999-
'id': <ANY>,
1000-
'labels': set({
1001-
}),
1002-
'name': None,
1003-
'options': dict({
1004-
}),
1005-
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
1006-
'original_icon': None,
1007-
'original_name': 'Relay',
1008-
'platform': 'plugwise',
1009-
'previous_unique_id': None,
1010-
'suggested_object_id': None,
1011-
'supported_features': 0,
1012-
'translation_key': 'relay',
1013-
'unique_id': 'd03738edfcc947f7b8f4573571d90d2d-relay',
1014-
'unit_of_measurement': None,
1015-
})
1016-
# ---
1017-
# name: test_stretch_switch_snapshot[platforms0][switch.schakel_relay-state]
1018-
StateSnapshot({
1019-
'attributes': ReadOnlyDict({
1020-
'device_class': 'switch',
1021-
'friendly_name': 'Schakel Relay',
1022-
}),
1023-
'context': <ANY>,
1024-
'entity_id': 'switch.schakel_relay',
1025-
'last_changed': <ANY>,
1026-
'last_reported': <ANY>,
1027-
'last_updated': <ANY>,
1028-
'state': 'on',
1029-
})
1030-
# ---
1031-
# name: test_stretch_switch_snapshot[platforms0][switch.stroomvreters_relay-entry]
1032-
EntityRegistryEntrySnapshot({
1033-
'aliases': set({
1034-
}),
1035-
'area_id': None,
1036-
'capabilities': None,
1037-
'config_entry_id': <ANY>,
1038-
'config_subentry_id': <ANY>,
1039-
'device_class': None,
1040-
'device_id': <ANY>,
1041-
'disabled_by': None,
1042-
'domain': 'switch',
1043-
'entity_category': None,
1044-
'entity_id': 'switch.stroomvreters_relay',
1045-
'has_entity_name': True,
1046-
'hidden_by': None,
1047-
'icon': None,
1048-
'id': <ANY>,
1049-
'labels': set({
1050-
}),
1051-
'name': None,
1052-
'options': dict({
1053-
}),
1054-
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
1055-
'original_icon': None,
1056-
'original_name': 'Relay',
1057-
'platform': 'plugwise',
1058-
'previous_unique_id': None,
1059-
'suggested_object_id': None,
1060-
'supported_features': 0,
1061-
'translation_key': 'relay',
1062-
'unique_id': 'd950b314e9d8499f968e6db8d82ef78c-relay',
1063-
'unit_of_measurement': None,
1064-
})
1065-
# ---
1066-
# name: test_stretch_switch_snapshot[platforms0][switch.stroomvreters_relay-state]
1067-
StateSnapshot({
1068-
'attributes': ReadOnlyDict({
1069-
'device_class': 'switch',
1070-
'friendly_name': 'Stroomvreters Relay',
1071-
}),
1072-
'context': <ANY>,
1073-
'entity_id': 'switch.stroomvreters_relay',
1074-
'last_changed': <ANY>,
1075-
'last_reported': <ANY>,
1076-
'last_updated': <ANY>,
1077-
'state': 'on',
1078-
})
1079-
# ---
1080933
# name: test_stretch_switch_snapshot[platforms0][switch.vaatwasser_2a1ab_lock-entry]
1081934
EntityRegistryEntrySnapshot({
1082935
'aliases': set({

0 commit comments

Comments
 (0)