Skip to content

Commit b29517b

Browse files
authored
Merge pull request #259 from plugwise/production-fix
Bugfix: implement solution for production energy-logs problem
2 parents bea3cb8 + e5bd6ed commit b29517b

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Changelog
22

3-
## v0.44.1
3+
## v0.44.2 - 2025-06-11
4+
5+
- Bugfix: implement solution for Issue [#259](https://github.com/plugwise/plugwise_usb-beta/issues/259)
6+
7+
## v0.44.1 - 2025-06-10
48

59
- PR [#258](https://github.com/plugwise/python-plugwise-usb/pull/258)
610
- Sense: make sure NodeFeature.BATTERY is called and configuration parameters are propagated properly
711

8-
## v0.44.0
12+
## v0.44.0 - 2025-06-10
913

1014
- PR [#256](https://github.com/plugwise/python-plugwise-usb/pull/256) Implement PlugWise Sense product
1115

plugwise_usb/nodes/helpers/pulses.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,14 @@ def _update_log_direction(
503503
) -> None:
504504
"""Update Energy direction of log record.
505505
506-
Two subsequential logs with the same timestamp indicates the first
507-
is consumption and second production.
506+
Two subsequential logging slots with the same timestamp indicate
507+
both consumption and production logging is active.
508+
The first slot (e.g. 1) contains consumption data,
509+
the second slot (e.g. 2) production data.
510+
511+
This code expects either single slots containing consumption data
512+
or double slots containing consumption and production data.
513+
Single slots containing production data only is NOT supported/tested.
508514
"""
509515
if self._logs is None:
510516
return
@@ -513,10 +519,11 @@ def _update_log_direction(
513519
next_timestamp = self._check_next_production(address, slot, timestamp)
514520
if self._first_prev_log_processed and self._first_next_log_processed:
515521
# _log_production is True when 2 out of 3 consecutive slots have
516-
# the same timestamp, otherwise it is False
522+
# the same timestamp
517523
self._log_production = (
518-
next_timestamp == timestamp and prev_timestamp != timestamp
519-
) or (next_timestamp == prev_timestamp and next_timestamp != timestamp)
524+
(prev_timestamp == timestamp)
525+
^ (next_timestamp == timestamp)
526+
)
520527

521528
def _check_prev_production(
522529
self, address: int, slot: int, timestamp: datetime

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "plugwise_usb"
7-
version = "0.44.1"
7+
version = "0.44.2"
88
license = "MIT"
99
keywords = ["home", "automation", "plugwise", "module", "usb"]
1010
classifiers = [

0 commit comments

Comments
 (0)