diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bd4c5488..457bd0bf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.2.0 + +- Improve the low_battery feature, 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. diff --git a/plugwise/data.py b/plugwise/data.py index 4a984dda2..835fdb57c 100644 --- a/plugwise/data.py +++ b/plugwise/data.py @@ -62,15 +62,11 @@ def _update_gw_devices(self) -> None: self._add_or_update_notifications(device_id, device, data) device.update(data) - 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") 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 @@ -88,12 +84,15 @@ def _detect_low_batteries(self) -> list[str]: for msg_id, notification in list(self._notifications.items()): mac_address: str | None = None message: str | None = notification.get("message") - if message is not None and all(x in message for x in matches) and (mac_addresses := mac_pattern.findall(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: - self._notifications.pop(msg_id) 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 diff --git a/pyproject.toml b/pyproject.toml index 9745b94e2..eb255e41f 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.0" license = {file = "LICENSE"} description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3." readme = "README.md" 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" }, 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