Define entity attributes as entity class variables

This commit is contained in:
Franck Nijhof
2021-05-21 13:13:56 +02:00
parent 00208ff0d8
commit 7ff574b7ea

View File

@@ -168,6 +168,11 @@ class Entity(ABC):
# If entity is added to an entity platform # If entity is added to an entity platform
_added = False _added = False
# Entity Properties
_device_class: str | None = None
_icon: str | None = None
_unit_of_measurement: str | None = None
@property @property
def should_poll(self) -> bool: def should_poll(self) -> bool:
"""Return True if entity has to be polled for state. """Return True if entity has to be polled for state.
@@ -240,17 +245,17 @@ class Entity(ABC):
@property @property
def device_class(self) -> str | None: def device_class(self) -> str | None:
"""Return the class of this device, from component DEVICE_CLASSES.""" """Return the class of this device, from component DEVICE_CLASSES."""
return None return self._device_class
@property @property
def unit_of_measurement(self) -> str | None: def unit_of_measurement(self) -> str | None:
"""Return the unit of measurement of this entity, if any.""" """Return the unit of measurement of this entity, if any."""
return None return self._unit_of_measurement
@property @property
def icon(self) -> str | None: def icon(self) -> str | None:
"""Return the icon to use in the frontend, if any.""" """Return the icon to use in the frontend, if any."""
return None return self._icon
@property @property
def entity_picture(self) -> str | None: def entity_picture(self) -> str | None: