File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
plugwise_usb/nodes/helpers Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,22 @@ 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+ from_timestamp = from_timestamp + timedelta (
180+ minutes = self ._cons_last_hourly_reset .minute ,
181+ seconds = self ._cons_last_hourly_reset .second ,
182+ microseconds = self ._cons_last_hourly_reset .microsecond ,
183+ )
184+ else :
185+ from_timestamp = from_timestamp + timedelta (
186+ minutes = self ._prod_last_hourly_reset .minute ,
187+ seconds = self ._prod_last_hourly_reset .second ,
188+ microseconds = self ._prod_last_hourly_reset .microsecond ,
189+ )
190+
175191 _LOGGER .debug (
176192 "collected_pulses | %s | from_timestamp=%s | is_cons=%s | _log_production=%s" ,
177193 self ._mac ,
You can’t perform that action at this time.
0 commit comments