From 5ed44297e6de8492f5c851cc5bc4e638b6c47086 Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Tue, 31 Dec 2019 07:27:39 -0800 Subject: [PATCH] Simplify Tesla icon get code (#30301) * Simplify icon get code * Remove extraneous None --- homeassistant/components/tesla/__init__.py | 8 ++------ homeassistant/components/tesla/const.py | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/tesla/__init__.py b/homeassistant/components/tesla/__init__.py index a034d9132f1..1ae65f66821 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, SENSOR_ICONS, TESLA_COMPONENTS +from .const import DATA_LISTENER, DOMAIN, ICONS, TESLA_COMPONENTS _LOGGER = logging.getLogger(__name__) @@ -186,11 +186,7 @@ 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 - ) + self._icon = ICONS.get(self.tesla_device.type) @property def name(self): diff --git a/homeassistant/components/tesla/const.py b/homeassistant/components/tesla/const.py index 30a58b733ed..be460a430ac 100644 --- a/homeassistant/components/tesla/const.py +++ b/homeassistant/components/tesla/const.py @@ -9,7 +9,7 @@ TESLA_COMPONENTS = [ "device_tracker", "switch", ] -SENSOR_ICONS = { +ICONS = { "battery sensor": "mdi:battery", "range sensor": "mdi:gauge", "mileage sensor": "mdi:counter",