Skip to content

Commit 118dbab

Browse files
committed
Refactor to check against time range rather than round to seconds
*This shoud ensure 100% fix Signed-off-by: David Rapan <[email protected]>
1 parent 8522d73 commit 118dbab

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

homeassistant/components/starlink/sensor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ def native_value(self) -> datetime:
7575
new_value = super().native_value
7676
if TYPE_CHECKING:
7777
assert isinstance(new_value, datetime)
78-
if not self._attr_native_value or self._attr_native_value < new_value:
78+
if not self._attr_native_value or (
79+
self._attr_native_value + timedelta(minutes=1) < new_value
80+
):
7981
self._attr_native_value = new_value
8082
return self._attr_native_value
8183

@@ -166,9 +168,7 @@ async def async_added_to_hass(self) -> None:
166168
translation_key="last_boot_time",
167169
device_class=SensorDeviceClass.TIMESTAMP,
168170
entity_category=EntityCategory.DIAGNOSTIC,
169-
value_fn=lambda data: (
170-
now() - timedelta(seconds=data.status["uptime"], milliseconds=-500)
171-
).replace(microsecond=0),
171+
value_fn=lambda data: now() - timedelta(seconds=data.status["uptime"]),
172172
entity_class=StarlinkLastRestartSensor,
173173
),
174174
StarlinkSensorEntityDescription(

0 commit comments

Comments
 (0)