UniFi has changed to not report uptime in epoch form (#47492)
This commit is contained in:
parent
9a98dcf432
commit
597bf67f5a
2 changed files with 199 additions and 148 deletions
|
@ -3,6 +3,9 @@
|
|||
Support for bandwidth sensors of network clients.
|
||||
Support for uptime sensors of network clients.
|
||||
"""
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from homeassistant.components.sensor import DEVICE_CLASS_TIMESTAMP, DOMAIN
|
||||
from homeassistant.const import DATA_MEGABYTES
|
||||
from homeassistant.core import callback
|
||||
|
@ -140,8 +143,10 @@ class UniFiUpTimeSensor(UniFiClient):
|
|||
return f"{super().name} {self.TYPE.capitalize()}"
|
||||
|
||||
@property
|
||||
def state(self) -> int:
|
||||
def state(self) -> datetime:
|
||||
"""Return the uptime of the client."""
|
||||
if self.client.uptime < 1000000000:
|
||||
return (dt_util.now() - timedelta(seconds=self.client.uptime)).isoformat()
|
||||
return dt_util.utc_from_timestamp(float(self.client.uptime)).isoformat()
|
||||
|
||||
async def options_updated(self) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue