mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 05:35:11 +02:00
Define entity attributes as entity class variables
This commit is contained in:
@@ -168,6 +168,11 @@ class Entity(ABC):
|
||||
# If entity is added to an entity platform
|
||||
_added = False
|
||||
|
||||
# Entity Properties
|
||||
_device_class: str | None = None
|
||||
_icon: str | None = None
|
||||
_unit_of_measurement: str | None = None
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
"""Return True if entity has to be polled for state.
|
||||
@@ -240,17 +245,17 @@ class Entity(ABC):
|
||||
@property
|
||||
def device_class(self) -> str | None:
|
||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||
return None
|
||||
return self._device_class
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self) -> str | None:
|
||||
"""Return the unit of measurement of this entity, if any."""
|
||||
return None
|
||||
return self._unit_of_measurement
|
||||
|
||||
@property
|
||||
def icon(self) -> str | None:
|
||||
"""Return the icon to use in the frontend, if any."""
|
||||
return None
|
||||
return self._icon
|
||||
|
||||
@property
|
||||
def entity_picture(self) -> str | None:
|
||||
|
Reference in New Issue
Block a user