I never manage to fix this but the device from the Ubiquiti UniFi integration report the wrong UpTime.
I believe that some of the integration in my Raspberry PI / HAOS are using Unix epoch time
also the UniFi controller is not hosted on the same host but on a Ubiquiti UDM Pro.
E.g of the issue :
Phone 12 Pro Max Uptime
2679 weeks ago
any idea how I can fix this?
petro
(Petro)
May 9, 2021, 10:40am
2
It makes a timestamp sensor, go to dev tools → states page. Find the sensor and look at the datetime string in the state column. You should find out what it should be and compare it to what it is, then report it as an issue. The timestamp is generated by this code and it might need to be modified:
@property
def device_class(self) -> str:
"""Return device class."""
return DEVICE_CLASS_TIMESTAMP
@property
def name(self) -> str:
"""Return the name of the client."""
return f"{super().name} {self.TYPE.capitalize()}"
@property
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:
"""Config entry options are updated, remove entity if option is disabled."""
if not self.controller.option_allow_uptime_sensors:
await self.remove_item({self.client.mac})