@@ -89,7 +89,8 @@ def __init__(self, mac: str) -> None:
8989
9090 self ._hourly_reset = False
9191 self ._hourly_reset_passed = False
92- self ._hourly_reset_pulses : int = 0
92+ self ._hourly_reset_cons_pulses : int = 0
93+ self ._hourly_reset_prod_pulses : int = 0
9394 self ._logs : dict [int , dict [int , PulseLogRecord ]] | None = None
9495 self ._log_addresses_missing : list [int ] | None = None
9596 self ._log_production : bool | None = None
@@ -190,39 +191,43 @@ def collected_pulses(
190191 timestamp = self ._pulses_timestamp
191192 delta_cons_pulses = self ._pulses_consumption - self ._prev_pulses_consumption
192193 if self ._hourly_reset_passed :
193- pulses = delta_cons_pulses + self ._hourly_reset_pulses
194- self ._hourly_reset_pulses = pulses
194+ pulses = delta_cons_pulses + self ._hourly_reset_cons_pulses
195+ self ._hourly_reset_cons_pulses = pulses
195196 elif self ._hourly_reset :
196197 pulses = delta_cons_pulses
197- self ._hourly_reset_pulses = pulses
198+ self ._hourly_reset_cons_pulses = pulses
198199 self ._hourly_reset = False
199200 self ._hourly_reset_passed = True
200201 elif self ._pulsecounter_reset :
201- pulses = self ._pulses_consumption + self ._hourly_reset_pulses
202+ pulses = self ._pulses_consumption + self ._hourly_reset_cons_pulses
202203 self ._pulsecounter_reset = False
203204 else :
204- pulses = self ._prev_pulses_consumption + self ._hourly_reset_pulses + delta_cons_pulses
205+ pulses = self ._prev_pulses_consumption + self ._hourly_reset_cons_pulses + delta_cons_pulses
205206 if self ._prev_pulses_consumption == 0 :
206- pulses = self ._pulses_consumption + self ._hourly_reset_pulses
207+ pulses = self ._pulses_consumption + self ._hourly_reset_cons_pulses
207208
208209 self ._prev_pulses_consumption = self ._pulses_consumption
209210
210211 if not is_consumption and self ._pulses_production is not None :
211212 timestamp = self ._pulses_timestamp
212213 delta_prod_pulses = self ._pulses_production - self ._prev_pulses_production
213214 if self ._hourly_reset_passed :
214- pulses = delta_prod_pulses + self ._prev_pulses_production
215+ pulses = delta_prod_pulses + self ._hourly_reset_prod_pulses
216+ self ._hourly_reset_prod_pulses = pulses
215217 elif self ._hourly_reset :
216218 pulses = delta_prod_pulses
219+ self ._hourly_reset_prod_pulses = pulses
217220 self ._hourly_reset = False
218221 self ._hourly_reset_passed = True
219222 elif self ._pulsecounter_reset :
220- pulses = self ._pulses_consumption + self ._prev_pulses_production
223+ pulses = self ._pulses_production + self ._hourly_reset_prod_pulses
221224 self ._pulsecounter_reset = False
222225 else :
223- pulses = delta_prod_pulses + self ._prev_pulses_production
226+ pulses = self ._prev_pulses_production + self ._hourly_reset_prod_pulses + delta_prod_pulses
227+ if self ._prev_pulses_production == 0 :
228+ pulses = self ._pulses_production + self ._hourly_reset_prod_pulses
224229
225- self ._prev_pulses_production = pulses
230+ self ._prev_pulses_production = self . _pulses_production
226231
227232 if pulses is None :
228233 _LOGGER .debug (
0 commit comments