Skip to content

Commit 4f291b6

Browse files
committed
Fix _reset_log_references()
1 parent aa5be84 commit 4f291b6

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

plugwise_usb/nodes/helpers/pulses.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -599,37 +599,40 @@ def _reset_log_references(self) -> None:
599599
self._first_log_production_address = None
600600
self._first_log_production_slot = None
601601
self._first_log_production_timestamp = None
602+
602603
if self._logs is None:
603604
return
605+
604606
for address in self._logs:
605607
for slot, log_record in self._logs[address].items():
606608
if log_record.is_consumption:
607609
if self._last_log_consumption_timestamp is None:
608610
self._last_log_consumption_timestamp = log_record.timestamp
609611
if self._last_log_consumption_timestamp <= log_record.timestamp:
610612
self._last_log_consumption_timestamp = log_record.timestamp
611-
self._last_log_consumption_address = address
612-
self._last_log_consumption_slot = slot
613+
self._last_log_consumption_address = address
614+
self._last_log_consumption_slot = slot
613615

614616
if self._first_log_consumption_timestamp is None:
615617
self._first_log_consumption_timestamp = log_record.timestamp
616618
if self._first_log_consumption_timestamp >= log_record.timestamp:
617619
self._first_log_consumption_timestamp = log_record.timestamp
618-
self._first_log_consumption_address = address
619-
self._first_log_consumption_slot = slot
620+
self._first_log_consumption_address = address
621+
self._first_log_consumption_slot = slot
620622
else:
621623
if self._last_log_production_timestamp is None:
622624
self._last_log_production_timestamp = log_record.timestamp
623625
if self._last_log_production_timestamp <= log_record.timestamp:
624-
self._last_log_production_address = address
625-
self._last_log_production_slot = slot
626+
self._last_log_production_timestamp = log_record.timestamp
627+
self._last_log_production_address = address
628+
self._last_log_production_slot = slot
626629

627630
if self._first_log_production_timestamp is None:
628631
self._first_log_production_timestamp = log_record.timestamp
629632
if self._first_log_production_timestamp > log_record.timestamp:
630633
self._first_log_production_timestamp = log_record.timestamp
631-
self._first_log_production_address = address
632-
self._first_log_production_slot = slot
634+
self._first_log_production_address = address
635+
self._first_log_production_slot = slot
633636

634637
def _update_last_production_log_reference(
635638
self, address: int, slot: int, timestamp: datetime

0 commit comments

Comments
 (0)