plugwise 1.0.0__py3-none-any.whl → 1.1.0__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.0.dist-info}/METADATA +1 -1
- {plugwise-1.0.0.dist-info → plugwise-1.1.0.dist-info}/RECORD +9 -9
- {plugwise-1.0.0.dist-info → plugwise-1.1.0.dist-info}/WHEEL +1 -1
- {plugwise-1.0.0.dist-info → plugwise-1.1.0.dist-info}/LICENSE +0 -0
- {plugwise-1.0.0.dist-info → plugwise-1.1.0.dist-info}/top_level.txt +0 -0
plugwise/constants.py
CHANGED
@@ -264,6 +264,7 @@ BinarySensorType = Literal[
|
|
264
264
|
"dhw_state",
|
265
265
|
"flame_state",
|
266
266
|
"heating_state",
|
267
|
+
"low_battery",
|
267
268
|
"plugwise_notification",
|
268
269
|
"secondary_boiler_state",
|
269
270
|
]
|
@@ -415,6 +416,7 @@ class SmileBinarySensors(TypedDict, total=False):
|
|
415
416
|
dhw_state: bool
|
416
417
|
flame_state: bool
|
417
418
|
heating_state: bool
|
419
|
+
low_battery: bool
|
418
420
|
plugwise_notification: bool
|
419
421
|
secondary_boiler_state: bool
|
420
422
|
|
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 "low_battery" 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"]["low_battery"] = 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 low-battery 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"]["low_battery"] = False
|
143
|
+
|
141
144
|
|
142
145
|
def escape_illegal_xml_characters(xmldata: str) -> str:
|
143
146
|
"""Replace illegal &-characters."""
|
@@ -1,17 +1,17 @@
|
|
1
1
|
plugwise/__init__.py,sha256=EXiTp-N8kQqOUAaczDbULS176NwA2C1FcfWiKkBzNdI,16887
|
2
2
|
plugwise/common.py,sha256=P4sUYzgVcFsIR2DmQxeVeOiZvFZWpZXgwHA3XRc1Sx0,12538
|
3
|
-
plugwise/constants.py,sha256=
|
4
|
-
plugwise/data.py,sha256=
|
3
|
+
plugwise/constants.py,sha256=O2sEAUjoOgvuM5dsS7jzZOMDcy6h8WI1p-od9WzJvQ4,16722
|
4
|
+
plugwise/data.py,sha256=xekYAKTdpLpTjnhDKQwGh25TnZQxN7EypG7NDxPpnFI,10706
|
5
5
|
plugwise/exceptions.py,sha256=Ce-tO9uNsMB-8FP6VAxBvsHNJ-NIM9F0onUZOdZI4Ys,1110
|
6
6
|
plugwise/helper.py,sha256=NFcxVtY9qdM2TtBbGs-_eh7xKO6G_M3Q4W9bXUCpH84,43861
|
7
7
|
plugwise/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
plugwise/smile.py,sha256=
|
9
|
-
plugwise/util.py,sha256=
|
8
|
+
plugwise/smile.py,sha256=TyDXl1NSMFxsZehtopawpYpL6vie3NM3gVcez_bfjvA,18681
|
9
|
+
plugwise/util.py,sha256=NWqL4AnteOeEddXIuMR6mU5IQlcd4ZyUNjV_5sBbquQ,7922
|
10
10
|
plugwise/legacy/data.py,sha256=DsHR9xgiFDg_Vh_6ZpOskw8ZhNQ3CmwjstI3yiH6MEk,3048
|
11
11
|
plugwise/legacy/helper.py,sha256=6-tYQMEXepE5rec-hn6lt2EeknADI3J8UFuBSLgu8dk,17878
|
12
12
|
plugwise/legacy/smile.py,sha256=7oaPZuvxrYRvoA8qWFvtWSwQRFfQl1XXpPjWXn3_xFs,11314
|
13
|
-
plugwise-1.
|
14
|
-
plugwise-1.
|
15
|
-
plugwise-1.
|
16
|
-
plugwise-1.
|
17
|
-
plugwise-1.
|
13
|
+
plugwise-1.1.0.dist-info/LICENSE,sha256=mL22BjmXtg_wnoDnnaqps5_Bg_VGj_yHueX5lsKwbCc,1144
|
14
|
+
plugwise-1.1.0.dist-info/METADATA,sha256=tEeH1VnRXbLMNT5BGh4A7vlKug4oXe_A430-smR91e8,9097
|
15
|
+
plugwise-1.1.0.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
|
16
|
+
plugwise-1.1.0.dist-info/top_level.txt,sha256=MYOmktMFf8ZmX6_OE1y9MoCZFfY-L8DA0F2tA2IvE4s,9
|
17
|
+
plugwise-1.1.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|