Round finish_time to the minute to stop recorder spam
_finish_time added datetime.now(timezone.utc) (fresh seconds/ microseconds every call) to the device's remaining-time duration, so the returned timestamp differed at the sub-minute level on nearly every poll even when remainingTime itself hadn't changed. The recorder logged a new history/logbook entry each time, while the UI rounds the display down to the minute, making repeated polls look like duplicate identical entries. Round the result down to the minute so the entity only changes state when the estimate actually shifts.
This commit is contained in:
1 parent
e99a8a6b05
commit
fe9a1128ea
2 files changed
+36
-1
No files matched your search
@@ -90,7 +90,14 @@ def _finish_time(rep):
|
||||
total_s = _remaining_seconds(rep.get('x.com.samsung.da.remainingTime'))
|
||||
if not total_s:
|
||||
return None
|
||||
return datetime.now(timezone.utc) + timedelta(seconds=total_s)
|
||||
# Round to whole minutes -- remainingTime itself only has minute
|
||||
# resolution, but datetime.now() always carries fresh seconds/
|
||||
# microseconds, so an unrounded result changes on nearly every poll
|
||||
# even when the device-reported remaining time hasn't. That floods
|
||||
# the recorder history/logbook with values that look identical once
|
||||
# the UI rounds them down for display.
|
||||
finish = datetime.now(timezone.utc) + timedelta(seconds=total_s)
|
||||
return finish.replace(second=0, microsecond=0)
|
||||
|
||||
|
||||
def _completion_minutes(rep):
|
||||
|
||||
Reference in new issue
Block a user