Skip to content

Commit 70d58f6

Browse files
committed
Improve logic 5
1 parent 0ebd1e7 commit 70d58f6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

plugwise_usb/nodes/helpers/pulses.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ def collected_pulses(
201201
pulses = self._pulses_consumption + self._hourly_reset_pulses
202202
self._pulsecounter_reset = False
203203
else:
204-
pulses = self._prev_pulses_consumption + delta_cons_pulses
204+
pulses = self._prev_pulses_consumption + self._hourly_reset_pulses + delta_cons_pulses
205+
if self._prev_pulses_consumption == 0:
206+
pulses = self._pulses_consumption + self._hourly_reset_pulses
205207

206208
self._prev_pulses_consumption = self._pulses_consumption
207209

@@ -271,7 +273,9 @@ def _collect_pulses_from_logs(
271273

272274
timestamp = self._last_log_production_timestamp
273275

274-
if from_timestamp > timestamp and not self._hourly_reset_passed and not self._pulsecounter_reset:
276+
if from_timestamp > timestamp and not self._hourly_reset_passed and not self._pulsecounter_reset and (
277+
self._rollover_consumption or self._rollover_production
278+
):
275279
self._hourly_reset = True
276280

277281
missing_logs = self._logs_missing(from_timestamp)

0 commit comments

Comments
 (0)