From 660f0d159663e29285e12d9628766e99bb9fffb2 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Wed, 11 Jun 2025 08:02:51 +0200 Subject: [PATCH 1/7] Fix logic determining _log_production --- plugwise_usb/nodes/helpers/pulses.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugwise_usb/nodes/helpers/pulses.py b/plugwise_usb/nodes/helpers/pulses.py index 811254969..a030a736e 100644 --- a/plugwise_usb/nodes/helpers/pulses.py +++ b/plugwise_usb/nodes/helpers/pulses.py @@ -514,9 +514,9 @@ def _update_log_direction( if self._first_prev_log_processed and self._first_next_log_processed: # _log_production is True when 2 out of 3 consecutive slots have # the same timestamp, otherwise it is False - self._log_production = ( + self._log_production = ( next_timestamp == timestamp and prev_timestamp != timestamp - ) or (next_timestamp == prev_timestamp and next_timestamp != timestamp) + ) or (prev_timestamp == timestamp and next_timestamp != timestamp) def _check_prev_production( self, address: int, slot: int, timestamp: datetime From 202fc3b37858f33c92117dad456821ee77d56958 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Wed, 11 Jun 2025 08:03:51 +0200 Subject: [PATCH 2/7] Bump to v0.44.2a0 test-version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fa1198b93..2609657de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "plugwise_usb" -version = "0.44.1" +version = "0.44.2a0" license = "MIT" keywords = ["home", "automation", "plugwise", "module", "usb"] classifiers = [ From 512e1fe381eedfea8f14324105a5c22521ac112f Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Wed, 11 Jun 2025 11:07:22 +0200 Subject: [PATCH 3/7] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dadc7aee5..2932cfc09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.44.2 + +- Bugfix: implement solution for Issue [#259](https://github.com/plugwise/plugwise_usb-beta/issues/259) + ## v0.44.1 - PR [#258](https://github.com/plugwise/python-plugwise-usb/pull/258) From 70e0aca05eb07c6fde31ce9f6b2b2ccb8173c306 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Wed, 11 Jun 2025 11:13:20 +0200 Subject: [PATCH 4/7] Fix ident --- plugwise_usb/nodes/helpers/pulses.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugwise_usb/nodes/helpers/pulses.py b/plugwise_usb/nodes/helpers/pulses.py index a030a736e..571c10f32 100644 --- a/plugwise_usb/nodes/helpers/pulses.py +++ b/plugwise_usb/nodes/helpers/pulses.py @@ -514,7 +514,7 @@ def _update_log_direction( if self._first_prev_log_processed and self._first_next_log_processed: # _log_production is True when 2 out of 3 consecutive slots have # the same timestamp, otherwise it is False - self._log_production = ( + self._log_production = ( next_timestamp == timestamp and prev_timestamp != timestamp ) or (prev_timestamp == timestamp and next_timestamp != timestamp) From 0afddd770b3440270579b411f4ced1f5fb46d3bd Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Wed, 11 Jun 2025 13:13:34 +0200 Subject: [PATCH 5/7] Implement shorter notation as suggested Improve function docstring --- plugwise_usb/nodes/helpers/pulses.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/plugwise_usb/nodes/helpers/pulses.py b/plugwise_usb/nodes/helpers/pulses.py index 571c10f32..1bd8e81dc 100644 --- a/plugwise_usb/nodes/helpers/pulses.py +++ b/plugwise_usb/nodes/helpers/pulses.py @@ -503,8 +503,14 @@ def _update_log_direction( ) -> None: """Update Energy direction of log record. - Two subsequential logs with the same timestamp indicates the first - is consumption and second production. + Two subsequential logging slots with the same timestamp indicate + both consumption and production logging is active. + The first slot (e.g. 1) contains consumption data, + the second slot (e.g. 2) production data. + + This code expects either single slots containing consumption data + or double slots containing consumption and production data. + Single slots containing production data only is NOT supported/tested. """ if self._logs is None: return @@ -513,10 +519,11 @@ def _update_log_direction( next_timestamp = self._check_next_production(address, slot, timestamp) if self._first_prev_log_processed and self._first_next_log_processed: # _log_production is True when 2 out of 3 consecutive slots have - # the same timestamp, otherwise it is False + # the same timestamp self._log_production = ( - next_timestamp == timestamp and prev_timestamp != timestamp - ) or (prev_timestamp == timestamp and next_timestamp != timestamp) + (prev_timestamp == timestamp) + ^ (next_timestamp == timestamp) + ) def _check_prev_production( self, address: int, slot: int, timestamp: datetime From 8a6718976ef0ee0c8b3b380398b028826dbc250d Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Wed, 11 Jun 2025 13:19:34 +0200 Subject: [PATCH 6/7] Update CHANGELOG --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2932cfc09..e88e95631 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,15 @@ # Changelog -## v0.44.2 +## v0.44.2 - 2025-06-11 - Bugfix: implement solution for Issue [#259](https://github.com/plugwise/plugwise_usb-beta/issues/259) -## v0.44.1 +## v0.44.1 - 2025-06-10 - PR [#258](https://github.com/plugwise/python-plugwise-usb/pull/258) - Sense: make sure NodeFeature.BATTERY is called and configuration parameters are propagated properly -## v0.44.0 +## v0.44.0 - 2025-06-10 - PR [#256](https://github.com/plugwise/python-plugwise-usb/pull/256) Implement PlugWise Sense product From e5bd6ed88c7a920887125a34af40b00f12aba7e1 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Wed, 11 Jun 2025 13:20:02 +0200 Subject: [PATCH 7/7] Set to v0.44.2 release-version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2609657de..35532dce9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "plugwise_usb" -version = "0.44.2a0" +version = "0.44.2" license = "MIT" keywords = ["home", "automation", "plugwise", "module", "usb"] classifiers = [