Allow device class to control icons for tesla (#37526)
This commit is contained in:
parent
17c9e31e2c
commit
d89bfe79f9
1 changed files with 2 additions and 10 deletions
|
@ -15,12 +15,10 @@ from homeassistant.const import (
|
|||
CONF_SCAN_INTERVAL,
|
||||
CONF_TOKEN,
|
||||
CONF_USERNAME,
|
||||
DEVICE_CLASS_BATTERY,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.icon import icon_for_battery_level
|
||||
from homeassistant.util import slugify
|
||||
|
||||
from .config_flow import (
|
||||
|
@ -223,14 +221,8 @@ class TeslaDevice(Entity):
|
|||
@property
|
||||
def icon(self):
|
||||
"""Return the icon of the sensor."""
|
||||
if (
|
||||
self.device_class == DEVICE_CLASS_BATTERY
|
||||
and self.tesla_device.has_battery()
|
||||
):
|
||||
return icon_for_battery_level(
|
||||
battery_level=self.tesla_device.battery_level(),
|
||||
charging=self.tesla_device.battery_charging(),
|
||||
)
|
||||
if self.device_class:
|
||||
return None
|
||||
|
||||
return self._icon
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue