Skip to content

Commit bbeedb2

Browse files
committed
Follow CRAI suggestion fully
1 parent 5b5b3a6 commit bbeedb2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,11 @@ async def _energy_log_records_load_from_cache(self) -> bool:
662662
# Iterate in reverse sorted order directly
663663
for address in sorted(collected_logs, reverse=True):
664664
for slot in range(4, 0, -1):
665-
(timestamp, pulses) = collected_logs[address][slot]
665+
bucket = collected_logs.get(address, {})
666+
if slot not in bucket:
667+
continue
668+
(timestamp, pulses) = bucket[slot]
669+
# Keep only recent entries; prune older-or-equal than cutoff
666670
if timestamp <= skip_before:
667671
continue
668672
self._energy_counters.add_pulse_log(

0 commit comments

Comments
 (0)