mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Simplify Tesla icon get code (#30301)
* Simplify icon get code * Remove extraneous None
This commit is contained in:
parent
4031596aa7
commit
5ed44297e6
@ -26,7 +26,7 @@ from .config_flow import (
|
|||||||
configured_instances,
|
configured_instances,
|
||||||
validate_input,
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -186,11 +186,7 @@ class TeslaDevice(Entity):
|
|||||||
self._name = self.tesla_device.name
|
self._name = self.tesla_device.name
|
||||||
self.tesla_id = slugify(self.tesla_device.uniq_name)
|
self.tesla_id = slugify(self.tesla_device.uniq_name)
|
||||||
self._attributes = {}
|
self._attributes = {}
|
||||||
self._icon = (
|
self._icon = ICONS.get(self.tesla_device.type)
|
||||||
SENSOR_ICONS[self.tesla_device.type]
|
|
||||||
if self.tesla_device.type and self.tesla_device.type in SENSOR_ICONS.keys()
|
|
||||||
else None
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
@ -9,7 +9,7 @@ TESLA_COMPONENTS = [
|
|||||||
"device_tracker",
|
"device_tracker",
|
||||||
"switch",
|
"switch",
|
||||||
]
|
]
|
||||||
SENSOR_ICONS = {
|
ICONS = {
|
||||||
"battery sensor": "mdi:battery",
|
"battery sensor": "mdi:battery",
|
||||||
"range sensor": "mdi:gauge",
|
"range sensor": "mdi:gauge",
|
||||||
"mileage sensor": "mdi:counter",
|
"mileage sensor": "mdi:counter",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user