File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
plugwise_usb/nodes/helpers Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,23 @@ def collected_pulses(
172172 self , from_timestamp : datetime , is_consumption : bool
173173 ) -> tuple [int | None , datetime | None ]:
174174 """Calculate total pulses from given timestamp."""
175+
176+ # Sync from_timestamp with the device pulsecounter reset-time
177+ # This syncs the hourly/daily reset of energy counters with the corresponding device pulsecounter reset
178+ if is_consumption :
179+ if self ._cons_last_hourly_reset is not None :
180+ from_timestamp = from_timestamp + timedelta (
181+ minutes = self ._cons_last_hourly_reset .minute ,
182+ seconds = self ._cons_last_hourly_reset .second ,
183+ microseconds = self ._cons_last_hourly_reset .microsecond ,
184+ )
185+ elif self ._prod_last_hourly_reset is not None :
186+ from_timestamp = from_timestamp + timedelta (
187+ minutes = self ._prod_last_hourly_reset .minute ,
188+ seconds = self ._prod_last_hourly_reset .second ,
189+ microseconds = self ._prod_last_hourly_reset .microsecond ,
190+ )
191+
175192 _LOGGER .debug (
176193 "collected_pulses | %s | from_timestamp=%s | is_cons=%s | _log_production=%s" ,
177194 self ._mac ,
You can’t perform that action at this time.
0 commit comments