Use attributes instead of properties for uptime (#52398)
* Use attributes instead of properties for uptime * add missing types
This commit is contained in:
parent
8e846164a4
commit
1337dfed8c
1 changed files with 4 additions and 22 deletions
|
@ -47,25 +47,7 @@ class UptimeSensor(SensorEntity):
|
|||
|
||||
def __init__(self, name: str) -> None:
|
||||
"""Initialize the uptime sensor."""
|
||||
self._name = name
|
||||
self._state = dt_util.now().isoformat()
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of the sensor."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def device_class(self) -> str:
|
||||
"""Return device class."""
|
||||
return DEVICE_CLASS_TIMESTAMP
|
||||
|
||||
@property
|
||||
def state(self) -> str:
|
||||
"""Return the state of the sensor."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
"""Disable polling for this entity."""
|
||||
return False
|
||||
self._attr_name: str = name
|
||||
self._attr_device_class: str = DEVICE_CLASS_TIMESTAMP
|
||||
self._attr_should_poll: bool = False
|
||||
self._attr_state: str = dt_util.now().isoformat()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue