plugwise 1.0.0__py3-none-any.whl → 1.1.0a0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plugwise/constants.py +2 -0
- plugwise/data.py +39 -1
- plugwise/smile.py +0 -1
- plugwise/util.py +3 -0
- {plugwise-1.0.0.dist-info → plugwise-1.1.0a0.dist-info}/METADATA +1 -1
- plugwise-1.1.0a0.dist-info/RECORD +17 -0
- {plugwise-1.0.0.dist-info → plugwise-1.1.0a0.dist-info}/WHEEL +1 -1
- plugwise-1.0.0.dist-info/RECORD +0 -17
- {plugwise-1.0.0.dist-info → plugwise-1.1.0a0.dist-info}/LICENSE +0 -0
- {plugwise-1.0.0.dist-info → plugwise-1.1.0a0.dist-info}/top_level.txt +0 -0
plugwise/constants.py
CHANGED
@@ -258,6 +258,7 @@ ApplianceType = Literal[
|
|
258
258
|
]
|
259
259
|
|
260
260
|
BinarySensorType = Literal[
|
261
|
+
"battery_state",
|
261
262
|
"compressor_state",
|
262
263
|
"cooling_enabled",
|
263
264
|
"cooling_state",
|
@@ -409,6 +410,7 @@ class ModelData(TypedDict):
|
|
409
410
|
class SmileBinarySensors(TypedDict, total=False):
|
410
411
|
"""Smile Binary Sensors class."""
|
411
412
|
|
413
|
+
battery_state: bool
|
412
414
|
compressor_state: bool
|
413
415
|
cooling_enabled: bool
|
414
416
|
cooling_state: bool
|
plugwise/data.py
CHANGED
@@ -4,6 +4,8 @@ Plugwise Smile protocol data-collection helpers.
|
|
4
4
|
"""
|
5
5
|
from __future__ import annotations
|
6
6
|
|
7
|
+
import re
|
8
|
+
|
7
9
|
from plugwise.constants import (
|
8
10
|
ADAM,
|
9
11
|
ANNA,
|
@@ -52,13 +54,49 @@ class SmileData(SmileHelper):
|
|
52
54
|
|
53
55
|
Collect data for each device and add to self.gw_devices.
|
54
56
|
"""
|
57
|
+
mac_list: list[str] = []
|
55
58
|
for device_id, device in self.gw_devices.items():
|
56
59
|
data = self._get_device_data(device_id)
|
57
|
-
|
60
|
+
if device_id == self.gateway_id:
|
61
|
+
mac_list = self._detect_low_batteries()
|
62
|
+
self._add_or_update_notifications(device_id, device, data)
|
63
|
+
|
58
64
|
device.update(data)
|
65
|
+
|
66
|
+
is_battery_low = (
|
67
|
+
mac_list
|
68
|
+
and "battery_state" in device["binary_sensors"]
|
69
|
+
and device["zigbee_mac_address"] in mac_list
|
70
|
+
and (
|
71
|
+
(device["dev_class"] in ("thermo_sensor", "thermostatic_radiator_valve") and device["sensors"]["battery"] < 30)
|
72
|
+
or (device["dev_class"] in ("zone_thermometer", "zone_thermostat") and device["sensors"]["battery"] < 15)
|
73
|
+
)
|
74
|
+
)
|
75
|
+
if is_battery_low:
|
76
|
+
device["binary_sensors"]["battery_state"] = True
|
77
|
+
|
59
78
|
self._update_for_cooling(device)
|
79
|
+
|
60
80
|
remove_empty_platform_dicts(device)
|
61
81
|
|
82
|
+
def _detect_low_batteries(self) -> list[str]:
|
83
|
+
"""Helper-function updating the battery_state binary_sensor status from a Battery-is-low message."""
|
84
|
+
mac_address_list: list[str] = []
|
85
|
+
mac_pattern = re.compile(r"(?:[0-9A-F]{2}){8}")
|
86
|
+
matches = ["Battery", "below"]
|
87
|
+
if self._notifications:
|
88
|
+
for msg_id, notification in list(self._notifications.items()):
|
89
|
+
mac_address: str | None = None
|
90
|
+
message: str | None = notification.get("message")
|
91
|
+
if message is not None and all(x in message for x in matches) and (mac_addresses := mac_pattern.findall(message)):
|
92
|
+
mac_address = mac_addresses[0] # re.findall() outputs a list
|
93
|
+
|
94
|
+
if mac_address is not None:
|
95
|
+
self._notifications.pop(msg_id)
|
96
|
+
mac_address_list.append(mac_address)
|
97
|
+
|
98
|
+
return mac_address_list
|
99
|
+
|
62
100
|
def _add_or_update_notifications(
|
63
101
|
self, device_id: str, device: DeviceData, data: DeviceData
|
64
102
|
) -> None:
|
plugwise/smile.py
CHANGED
@@ -129,7 +129,6 @@ class SmileAPI(SmileComm, SmileData):
|
|
129
129
|
|
130
130
|
async def async_update(self) -> PlugwiseData:
|
131
131
|
"""Perform an incremental update for updating the various device states."""
|
132
|
-
# Perform a full update at day-change
|
133
132
|
self.gw_data: GatewayData = {}
|
134
133
|
self.gw_devices: dict[str, DeviceData] = {}
|
135
134
|
try:
|
plugwise/util.py
CHANGED
@@ -138,6 +138,9 @@ def common_match_cases(
|
|
138
138
|
sp_key = cast(SpecialType, measurement)
|
139
139
|
data[sp_key] = value
|
140
140
|
|
141
|
+
if "battery" in data["sensors"]:
|
142
|
+
data["binary_sensors"]["battery_state"] = False
|
143
|
+
|
141
144
|
|
142
145
|
def escape_illegal_xml_characters(xmldata: str) -> str:
|
143
146
|
"""Replace illegal &-characters."""
|
@@ -0,0 +1,17 @@
|
|
1
|
+
plugwise/__init__.py,sha256=EXiTp-N8kQqOUAaczDbULS176NwA2C1FcfWiKkBzNdI,16887
|
2
|
+
plugwise/common.py,sha256=P4sUYzgVcFsIR2DmQxeVeOiZvFZWpZXgwHA3XRc1Sx0,12538
|
3
|
+
plugwise/constants.py,sha256=Vuy_N7ZXxO3y2Z2BdlkOia82IPuHD3gNtMyxPmS4zcE,16726
|
4
|
+
plugwise/data.py,sha256=zNNhl2Y0fl8TJvMexVdPYd7QM_3fAxfiYKeG9GjCDlI,10712
|
5
|
+
plugwise/exceptions.py,sha256=Ce-tO9uNsMB-8FP6VAxBvsHNJ-NIM9F0onUZOdZI4Ys,1110
|
6
|
+
plugwise/helper.py,sha256=NFcxVtY9qdM2TtBbGs-_eh7xKO6G_M3Q4W9bXUCpH84,43861
|
7
|
+
plugwise/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
+
plugwise/smile.py,sha256=TyDXl1NSMFxsZehtopawpYpL6vie3NM3gVcez_bfjvA,18681
|
9
|
+
plugwise/util.py,sha256=nuFJccqrvHv7s8Ox24NQvDKMRXjFLKAwsgQ7nYaJne0,7924
|
10
|
+
plugwise/legacy/data.py,sha256=DsHR9xgiFDg_Vh_6ZpOskw8ZhNQ3CmwjstI3yiH6MEk,3048
|
11
|
+
plugwise/legacy/helper.py,sha256=6-tYQMEXepE5rec-hn6lt2EeknADI3J8UFuBSLgu8dk,17878
|
12
|
+
plugwise/legacy/smile.py,sha256=7oaPZuvxrYRvoA8qWFvtWSwQRFfQl1XXpPjWXn3_xFs,11314
|
13
|
+
plugwise-1.1.0a0.dist-info/LICENSE,sha256=mL22BjmXtg_wnoDnnaqps5_Bg_VGj_yHueX5lsKwbCc,1144
|
14
|
+
plugwise-1.1.0a0.dist-info/METADATA,sha256=6BXYBWp6gBDkWiE1DrEinbUtLpHf7G7WqpJjHZfU5U8,9099
|
15
|
+
plugwise-1.1.0a0.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
|
16
|
+
plugwise-1.1.0a0.dist-info/top_level.txt,sha256=MYOmktMFf8ZmX6_OE1y9MoCZFfY-L8DA0F2tA2IvE4s,9
|
17
|
+
plugwise-1.1.0a0.dist-info/RECORD,,
|
plugwise-1.0.0.dist-info/RECORD
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
plugwise/__init__.py,sha256=EXiTp-N8kQqOUAaczDbULS176NwA2C1FcfWiKkBzNdI,16887
|
2
|
-
plugwise/common.py,sha256=P4sUYzgVcFsIR2DmQxeVeOiZvFZWpZXgwHA3XRc1Sx0,12538
|
3
|
-
plugwise/constants.py,sha256=Y8DeuZSK2_2ZDPMwFtlGkNZKvqaE-WYl-s4fZsj4XZ4,16681
|
4
|
-
plugwise/data.py,sha256=HA3OoLrTad4ytns6_rfygwu8eGfopHJBNADGs-hvaQk,9054
|
5
|
-
plugwise/exceptions.py,sha256=Ce-tO9uNsMB-8FP6VAxBvsHNJ-NIM9F0onUZOdZI4Ys,1110
|
6
|
-
plugwise/helper.py,sha256=NFcxVtY9qdM2TtBbGs-_eh7xKO6G_M3Q4W9bXUCpH84,43861
|
7
|
-
plugwise/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
plugwise/smile.py,sha256=EgQHGl6kRghB5Ub_TBmUfIFMHI8AZ6INJl1nLoIjQ0Q,18727
|
9
|
-
plugwise/util.py,sha256=9ld46KJHWFze2eUrVSgUYn0g3zNerlpboM0iUa0H3ak,7830
|
10
|
-
plugwise/legacy/data.py,sha256=DsHR9xgiFDg_Vh_6ZpOskw8ZhNQ3CmwjstI3yiH6MEk,3048
|
11
|
-
plugwise/legacy/helper.py,sha256=6-tYQMEXepE5rec-hn6lt2EeknADI3J8UFuBSLgu8dk,17878
|
12
|
-
plugwise/legacy/smile.py,sha256=7oaPZuvxrYRvoA8qWFvtWSwQRFfQl1XXpPjWXn3_xFs,11314
|
13
|
-
plugwise-1.0.0.dist-info/LICENSE,sha256=mL22BjmXtg_wnoDnnaqps5_Bg_VGj_yHueX5lsKwbCc,1144
|
14
|
-
plugwise-1.0.0.dist-info/METADATA,sha256=AOW18FYvwY2m9USnOIiPiF3YOHB9c3ll-Y2ac5M4MW0,9097
|
15
|
-
plugwise-1.0.0.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
16
|
-
plugwise-1.0.0.dist-info/top_level.txt,sha256=MYOmktMFf8ZmX6_OE1y9MoCZFfY-L8DA0F2tA2IvE4s,9
|
17
|
-
plugwise-1.0.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|