From 2bb1581d1c593f94712c86c0f5826f5a68223766 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 12:49:18 +0200 Subject: [PATCH 01/15] Remove own added battery-low limits, not working Plugwise changes the message to a warning notification when the battery-level becomes critically low. --- plugwise/data.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugwise/data.py b/plugwise/data.py index 4a984dda2..956d62f61 100644 --- a/plugwise/data.py +++ b/plugwise/data.py @@ -67,10 +67,7 @@ def _update_gw_devices(self) -> None: mac_list and "low_battery" in device["binary_sensors"] and device["zigbee_mac_address"] in mac_list - and ( - (device["dev_class"] in ("thermo_sensor", "thermostatic_radiator_valve") and device["sensors"]["battery"] < 30) - or (device["dev_class"] in ("zone_thermometer", "zone_thermostat") and device["sensors"]["battery"] < 15) - ) + and device["dev_class"] in ("thermo_sensor", "thermostatic_radiator_valve", "zone_thermometer", "zone_thermostat") ) if is_battery_low: device["binary_sensors"]["low_battery"] = True From d4234812c577243b2266ef7c596ea3c544478be7 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 12:59:57 +0200 Subject: [PATCH 02/15] Capture both battery-below notifications --- plugwise/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugwise/data.py b/plugwise/data.py index 956d62f61..b80653367 100644 --- a/plugwise/data.py +++ b/plugwise/data.py @@ -84,7 +84,7 @@ def _detect_low_batteries(self) -> list[str]: if self._notifications: for msg_id, notification in list(self._notifications.items()): mac_address: str | None = None - message: str | None = notification.get("message") + message: str | None = notification.get("message") or notification.get("warning") if message is not None and all(x in message for x in matches) and (mac_addresses := mac_pattern.findall(message)): mac_address = mac_addresses[0] # re.findall() outputs a list From 1146de7394c1f6f187ac0b996c70dc80bb771774 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 14:33:13 +0200 Subject: [PATCH 03/15] Keep showing battery-low warnings --- plugwise/data.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugwise/data.py b/plugwise/data.py index b80653367..548bb3d11 100644 --- a/plugwise/data.py +++ b/plugwise/data.py @@ -84,11 +84,13 @@ def _detect_low_batteries(self) -> list[str]: if self._notifications: for msg_id, notification in list(self._notifications.items()): mac_address: str | None = None - message: str | None = notification.get("message") or notification.get("warning") - if message is not None and all(x in message for x in matches) and (mac_addresses := mac_pattern.findall(message)): + message: str | None = notification.get("message") + warning: str | None = notification.get("warning") + notify = message or warning + if notify is not None and all(x in notify for x in matches) and (mac_addresses := mac_pattern.findall(notify)): mac_address = mac_addresses[0] # re.findall() outputs a list - if mac_address is not None: + if mac_address is not None and message is not None: # only block message-type notifications self._notifications.pop(msg_id) mac_address_list.append(mac_address) From 098d75999e86cb7996d0aaf6f3a03215a84ac626 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 14:47:06 +0200 Subject: [PATCH 04/15] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bd4c5488..2344431a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.2.0 + +- Improve the low_battery-related code, also take the battery-critically-low warning notification into account. + ## v1.1.0 - New Feature: add a low_battery binary_sensor for battery-powered devices and block the related battery-low notifications. From f68694d87eab1288d6cd463b055e60de7c3d8b46 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 15:00:45 +0200 Subject: [PATCH 05/15] Bump to v1.2.0a0 test-version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9745b94e2..f3b8ab028 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "plugwise" -version = "1.1.0" +version = "1.2.0a0" license = {file = "LICENSE"} description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3." readme = "README.md" From f83d958ce87525a5422c5a78ab2918de219e3023 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 17:16:21 +0200 Subject: [PATCH 06/15] Add debug-logging --- plugwise/data.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugwise/data.py b/plugwise/data.py index 548bb3d11..0ccfac9a3 100644 --- a/plugwise/data.py +++ b/plugwise/data.py @@ -63,12 +63,14 @@ def _update_gw_devices(self) -> None: device.update(data) + LOGGER.debug("HOI mac-list: %s", mac_list) is_battery_low = ( mac_list and "low_battery" in device["binary_sensors"] and device["zigbee_mac_address"] in mac_list and device["dev_class"] in ("thermo_sensor", "thermostatic_radiator_valve", "zone_thermometer", "zone_thermostat") ) + LOGGER.debug("HOI battery-low: %s", is_battery_low) if is_battery_low: device["binary_sensors"]["low_battery"] = True From 3c9cbb96dced66b35e61c3c7f6b19cd2fc48f355 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 17:17:08 +0200 Subject: [PATCH 07/15] Bump to a1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f3b8ab028..59816453a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "plugwise" -version = "1.2.0a0" +version = "1.2.0a1" license = {file = "LICENSE"} description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3." readme = "README.md" From 1cbe4a57114ab45ee57023ad5eddb9d5a7ec03ff Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 17:18:32 +0200 Subject: [PATCH 08/15] Import LOGGER --- plugwise/data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugwise/data.py b/plugwise/data.py index 0ccfac9a3..fd7ac3477 100644 --- a/plugwise/data.py +++ b/plugwise/data.py @@ -9,6 +9,7 @@ from plugwise.constants import ( ADAM, ANNA, + LOGGER, MAX_SETPOINT, MIN_SETPOINT, NONE, From 4fbff512e924129bdc50e671a1ad10c02fecc804 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 17:38:34 +0200 Subject: [PATCH 09/15] More debugging, fix code --- plugwise/data.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugwise/data.py b/plugwise/data.py index fd7ac3477..296d08032 100644 --- a/plugwise/data.py +++ b/plugwise/data.py @@ -90,12 +90,14 @@ def _detect_low_batteries(self) -> list[str]: message: str | None = notification.get("message") warning: str | None = notification.get("warning") notify = message or warning + LOGGER.debug("HOI result: %s", notify) if notify is not None and all(x in notify for x in matches) and (mac_addresses := mac_pattern.findall(notify)): mac_address = mac_addresses[0] # re.findall() outputs a list - if mac_address is not None and message is not None: # only block message-type notifications - self._notifications.pop(msg_id) + if mac_address is not None: mac_address_list.append(mac_address) + if message is not None: # only block message-type notifications + self._notifications.pop(msg_id) return mac_address_list From c1ee6c59924b761ce58d3dc807ec7bf94bd33f2f Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 17:38:54 +0200 Subject: [PATCH 10/15] Bump to a2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 59816453a..79c0d4206 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "plugwise" -version = "1.2.0a1" +version = "1.2.0a2" license = {file = "LICENSE"} description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3." readme = "README.md" From acdc7f57ceae7bc7b7a062d6876152d355566feb Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 17:55:39 +0200 Subject: [PATCH 11/15] Remove debug-logging --- plugwise/data.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plugwise/data.py b/plugwise/data.py index 296d08032..835fdb57c 100644 --- a/plugwise/data.py +++ b/plugwise/data.py @@ -9,7 +9,6 @@ from plugwise.constants import ( ADAM, ANNA, - LOGGER, MAX_SETPOINT, MIN_SETPOINT, NONE, @@ -63,15 +62,12 @@ def _update_gw_devices(self) -> None: self._add_or_update_notifications(device_id, device, data) device.update(data) - - LOGGER.debug("HOI mac-list: %s", mac_list) is_battery_low = ( mac_list and "low_battery" in device["binary_sensors"] and device["zigbee_mac_address"] in mac_list and device["dev_class"] in ("thermo_sensor", "thermostatic_radiator_valve", "zone_thermometer", "zone_thermostat") ) - LOGGER.debug("HOI battery-low: %s", is_battery_low) if is_battery_low: device["binary_sensors"]["low_battery"] = True @@ -90,7 +86,6 @@ def _detect_low_batteries(self) -> list[str]: message: str | None = notification.get("message") warning: str | None = notification.get("warning") notify = message or warning - LOGGER.debug("HOI result: %s", notify) if notify is not None and all(x in notify for x in matches) and (mac_addresses := mac_pattern.findall(notify)): mac_address = mac_addresses[0] # re.findall() outputs a list From 2cd8e1b5ce7e8aaa968da4776b45572ede118279 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 17:57:09 +0200 Subject: [PATCH 12/15] Bump to v1.2.0 release-version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 79c0d4206..eb255e41f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "plugwise" -version = "1.2.0a2" +version = "1.2.0" license = {file = "LICENSE"} description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3." readme = "README.md" From 465a0323ebc28655d44aca0922f8faf7a1722ada Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 17:58:14 +0200 Subject: [PATCH 13/15] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2344431a4..457bd0bf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## v1.2.0 -- Improve the low_battery-related code, also take the battery-critically-low warning notification into account. +- Improve the low_battery feature, also take the battery-critically-low warning notification into account. ## v1.1.0 From a3d09e5037ca2435607bd3a6ba0a957d7022f13f Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 18:07:06 +0200 Subject: [PATCH 14/15] Add battery-state critically low message to userddata --- .../core.domain_objects.xml | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/userdata/updated/adam_plus_anna_new/core.domain_objects.xml b/userdata/updated/adam_plus_anna_new/core.domain_objects.xml index 8b9d83c03..24ff7e482 100644 --- a/userdata/updated/adam_plus_anna_new/core.domain_objects.xml +++ b/userdata/updated/adam_plus_anna_new/core.domain_objects.xml @@ -171,18 +171,30 @@ - + warning local - Plug has been unreachable since 23:03 2020-01-18. + Plug has been unreachable since 23:03 2023-12-21. Node Plug (with MAC address 000D6F000D13CB01, in room 'n.a.') has been unreachable since 23:03 2020-01-18. Please check the connection and restart the device. - 2020-01-23T10:54:59.710+01:00 - 2020-01-18T23:03:43.689+01:00 - 2020-01-18T23:03:43.749+01:00 + 2023-12-22T10:54:59.710+01:00 + 2023-12-21T22:03:43.689+01:00 + 2023-12-21T22:03:43.749+01:00 + + warning + local + Battery of Lisa is critically low. + Battery of Lisa (with MAC address 000D6F000C869B61, in room 'Bathroom') is below the critical level of 15%. Please replace the battery or connect the device to a power adapter. + + + + 2023-12-21T08:06:18.095+02:00 + 2023-12-21T08:06:18.164+02:00 + + 2021-12-16T19:30:15.976+01:00 2023-12-22T16:30:02.561+01:00 From d2aecdbee5d92e19e52824030320070438aedce0 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 25 Aug 2024 18:09:07 +0200 Subject: [PATCH 15/15] Update related test-assert --- tests/data/adam/adam_plus_anna_new_UPDATED_DATA.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/adam/adam_plus_anna_new_UPDATED_DATA.json b/tests/data/adam/adam_plus_anna_new_UPDATED_DATA.json index ecf666f27..8737eb503 100644 --- a/tests/data/adam/adam_plus_anna_new_UPDATED_DATA.json +++ b/tests/data/adam/adam_plus_anna_new_UPDATED_DATA.json @@ -28,7 +28,7 @@ }, "e2f4322d57924fa090fbbc48b3a140dc": { "binary_sensors": { - "low_battery": false + "low_battery": true }, "mode": "off" },