Reduce state updates for OctoPrint (#70146)

pull/69048/head
Sebastian Lövdahl 2022-04-18 22:33:40 +03:00 committed by GitHub
parent f4d4b52204
commit 8f4979ea17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -187,7 +187,9 @@ class OctoPrintEstimatedFinishTimeSensor(OctoPrintSensorBase):
read_time = self.coordinator.data["last_read_time"]
return read_time + timedelta(seconds=job.progress.print_time_left)
return (read_time + timedelta(seconds=job.progress.print_time_left)).replace(
second=0
)
class OctoPrintStartTimeSensor(OctoPrintSensorBase):
@ -215,7 +217,9 @@ class OctoPrintStartTimeSensor(OctoPrintSensorBase):
read_time = self.coordinator.data["last_read_time"]
return read_time - timedelta(seconds=job.progress.print_time)
return (read_time - timedelta(seconds=job.progress.print_time)).replace(
second=0
)
class OctoPrintTemperatureSensor(OctoPrintSensorBase):

View File

@ -23,7 +23,7 @@ async def test_sensors(hass):
}
with patch(
"homeassistant.util.dt.utcnow",
return_value=datetime(2020, 2, 20, 9, 10, 0, tzinfo=timezone.utc),
return_value=datetime(2020, 2, 20, 9, 10, 13, 543, tzinfo=timezone.utc),
):
await init_integration(hass, "sensor", printer=printer, job=job)