1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Reduce state updates for OctoPrint (#70146)

This commit is contained in:
Sebastian Lövdahl
2022-04-18 22:33:40 +03:00
committed by GitHub
parent f4d4b52204
commit 8f4979ea17
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)