Simplify Tesla icon get code (#30301)

* Simplify icon get code

* Remove extraneous None
This commit is contained in:
Alan Tse 2019-12-31 07:27:39 -08:00 committed by springstan
parent 4031596aa7
commit 5ed44297e6
2 changed files with 3 additions and 7 deletions

View File

@ -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):

View File

@ -9,7 +9,7 @@ TESLA_COMPONENTS = [
"device_tracker",
"switch",
]
SENSOR_ICONS = {
ICONS = {
"battery sensor": "mdi:battery",
"range sensor": "mdi:gauge",
"mileage sensor": "mdi:counter",