Skip to content

Commit 2bc498b

Browse files
committed
Add_log(): support both cons-/prod-type of logs
1 parent f4ad4ab commit 2bc498b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

plugwise_usb/nodes/helpers/pulses.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,11 @@ def add_log(
384384
import_only: bool = False,
385385
) -> bool:
386386
"""Store pulse log."""
387-
log_record = PulseLogRecord(timestamp, pulses, CONSUMED)
387+
direction = CONSUMED
388+
if self._log_production and pulses < 0:
389+
direction = PRODUCED
390+
391+
log_record = PulseLogRecord(timestamp, pulses, direction)
388392
if not self._add_log_record(address, slot, log_record):
389393
if not self._log_exists(address, slot):
390394
return False

0 commit comments

Comments
 (0)