Skip to content

Commit 78d57b2

Browse files
committed
Add debug logging
1 parent 354e93e commit 78d57b2

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

plugwise_usb/nodes/helpers/pulses.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,21 @@ def _update_log_direction(
504504
if self._logs is None:
505505
return
506506

507+
_LOGGER.debug(
508+
"_update_log_direction | address=%s | slot=%s | timestamp=%s",
509+
address,
510+
slot,
511+
timestamp,
512+
)
507513
prev_address, prev_slot = calc_log_address(address, slot, -1)
508514
if self._log_exists(prev_address, prev_slot):
509515
timestamp_2 = self._logs[prev_address][prev_slot].timestamp
516+
_LOGGER.debug(
517+
"_update_log_direction | pr_address=%s | pr_slot=%s | timestamp=%s",
518+
prev_address,
519+
prev_slot,
520+
timestamp_2,
521+
)
510522
if timestamp_2 == timestamp:
511523
# Given log is the second log with same timestamp,
512524
# mark direction as production
@@ -524,6 +536,12 @@ def _update_log_direction(
524536
prev_prev_address, prev_prev_slot = calc_log_address(address, slot, -2)
525537
if self._log_exists(prev_prev_address, prev_prev_slot):
526538
timestamp_3 = self._logs[prev_prev_address][prev_prev_slot].timestamp
539+
_LOGGER.debug(
540+
"_update_log_direction | pr2_address=%s | pr2_slot=%s | timestamp=%s",
541+
prev_prev_address,
542+
prev_prev_slot,
543+
timestamp_3,
544+
)
527545
# _log_production is True when 2 out of 3 consecutive slots have
528546
# the same timestamp, otherwise it is False
529547
self._log_production = (
@@ -532,7 +550,14 @@ def _update_log_direction(
532550

533551
next_address, next_slot = calc_log_address(address, slot, 1)
534552
if self._log_exists(next_address, next_slot):
535-
if self._logs[next_address][next_slot].timestamp == timestamp:
553+
next_timestamp = self._logs[next_address][next_slot].timestamp
554+
_LOGGER.debug(
555+
"_update_log_direction | nxt_address=%s | nxt_slot=%s | timestamp=%s",
556+
next_address,
557+
next_slot,
558+
next_timestamp,
559+
)
560+
if next_timestamp == timestamp:
536561
# Given log is the first log with same timestamp,
537562
# mark direction as production of next log
538563
self._logs[address][slot].is_consumption = True

0 commit comments

Comments
 (0)