From 40e3d6f773042e67d128694d63010232a3bce494 Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Mon, 30 Dec 2019 08:52:34 -0800 Subject: [PATCH] Change default icons for Tesla components (#30288) --- homeassistant/components/tesla/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/tesla/__init__.py b/homeassistant/components/tesla/__init__.py index dbfe07271ee..a034d9132f1 100644 --- a/homeassistant/components/tesla/__init__.py +++ b/homeassistant/components/tesla/__init__.py @@ -26,7 +26,7 @@ from .config_flow import ( configured_instances, validate_input, ) -from .const import DATA_LISTENER, DOMAIN, TESLA_COMPONENTS +from .const import DATA_LISTENER, DOMAIN, SENSOR_ICONS, TESLA_COMPONENTS _LOGGER = logging.getLogger(__name__) @@ -186,6 +186,11 @@ class TeslaDevice(Entity): self._name = self.tesla_device.name self.tesla_id = slugify(self.tesla_device.uniq_name) self._attributes = {} + self._icon = ( + SENSOR_ICONS[self.tesla_device.type] + if self.tesla_device.type and self.tesla_device.type in SENSOR_ICONS.keys() + else None + ) @property def name(self): @@ -197,6 +202,11 @@ class TeslaDevice(Entity): """Return a unique ID.""" return self.tesla_id + @property + def icon(self): + """Return the icon of the sensor.""" + return self._icon + @property def should_poll(self): """Return the polling state."""