mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Define sensor entity attributes as class variables (#50942)
This commit is contained in:
parent
38d095aa18
commit
f7bc456bd2
@ -96,15 +96,18 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
class SensorEntity(Entity):
|
class SensorEntity(Entity):
|
||||||
"""Base class for sensor entities."""
|
"""Base class for sensor entities."""
|
||||||
|
|
||||||
|
_attr_state_class: str | None = None
|
||||||
|
_attr_last_reset: datetime | None = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state_class(self) -> str | None:
|
def state_class(self) -> str | None:
|
||||||
"""Return the state class of this entity, from STATE_CLASSES, if any."""
|
"""Return the state class of this entity, from STATE_CLASSES, if any."""
|
||||||
return None
|
return self._attr_state_class
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def last_reset(self) -> datetime | None:
|
def last_reset(self) -> datetime | None:
|
||||||
"""Return the time when the sensor was last reset, if any."""
|
"""Return the time when the sensor was last reset, if any."""
|
||||||
return None
|
return self._attr_last_reset
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def capability_attributes(self) -> Mapping[str, Any] | None:
|
def capability_attributes(self) -> Mapping[str, Any] | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user