Reduce state updates for OctoPrint (#70146)
parent
f4d4b52204
commit
8f4979ea17
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue