Collection of changing entity properties to class attributes - 2 (#51345)

This commit is contained in:
Franck Nijhof 2021-06-01 21:43:55 +02:00 committed by GitHub
parent e5dff49440
commit fcdd8b11a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 70 additions and 215 deletions

View file

@ -184,6 +184,8 @@ class IPPPrinterSensor(IPPSensor):
class IPPUptimeSensor(IPPSensor):
"""Defines a IPP uptime sensor."""
_attr_device_class = DEVICE_CLASS_TIMESTAMP
def __init__(
self, entry_id: str, unique_id: str, coordinator: IPPDataUpdateCoordinator
) -> None:
@ -203,8 +205,3 @@ class IPPUptimeSensor(IPPSensor):
"""Return the state of the sensor."""
uptime = utcnow() - timedelta(seconds=self.coordinator.data.info.uptime)
return uptime.replace(microsecond=0).isoformat()
@property
def device_class(self) -> str | None:
"""Return the class of this sensor."""
return DEVICE_CLASS_TIMESTAMP