Use native datetime value in UniFi sensors (#59926)

This commit is contained in:
Franck Nijhof
2021-11-19 07:35:09 +01:00
committed by GitHub
parent a3d5aec778
commit f7b7786d0d

View File

@@ -172,8 +172,8 @@ class UniFiUpTimeSensor(UniFiClient, SensorEntity):
def native_value(self) -> datetime: def native_value(self) -> datetime:
"""Return the uptime of the client.""" """Return the uptime of the client."""
if self.client.uptime < 1000000000: if self.client.uptime < 1000000000:
return (dt_util.now() - timedelta(seconds=self.client.uptime)).isoformat() return dt_util.now() - timedelta(seconds=self.client.uptime)
return dt_util.utc_from_timestamp(float(self.client.uptime)).isoformat() return dt_util.utc_from_timestamp(float(self.client.uptime))
async def options_updated(self) -> None: async def options_updated(self) -> None:
"""Config entry options are updated, remove entity if option is disabled.""" """Config entry options are updated, remove entity if option is disabled."""