From 7ff574b7ea8121fe3fba8ba7a5acc890f04babfb Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Fri, 21 May 2021 13:13:56 +0200 Subject: [PATCH] Define entity attributes as entity class variables --- homeassistant/helpers/entity.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 2e2c1b3b3f9..83ebb98b3e3 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -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: