mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Allow device class to control icons for tesla (#37526)
This commit is contained in:
parent
17c9e31e2c
commit
d89bfe79f9
@ -15,12 +15,10 @@ from homeassistant.const import (
|
|||||||
CONF_SCAN_INTERVAL,
|
CONF_SCAN_INTERVAL,
|
||||||
CONF_TOKEN,
|
CONF_TOKEN,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
DEVICE_CLASS_BATTERY,
|
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.icon import icon_for_battery_level
|
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
from .config_flow import (
|
from .config_flow import (
|
||||||
@ -223,14 +221,8 @@ class TeslaDevice(Entity):
|
|||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Return the icon of the sensor."""
|
"""Return the icon of the sensor."""
|
||||||
if (
|
if self.device_class:
|
||||||
self.device_class == DEVICE_CLASS_BATTERY
|
return None
|
||||||
and self.tesla_device.has_battery()
|
|
||||||
):
|
|
||||||
return icon_for_battery_level(
|
|
||||||
battery_level=self.tesla_device.battery_level(),
|
|
||||||
charging=self.tesla_device.battery_charging(),
|
|
||||||
)
|
|
||||||
|
|
||||||
return self._icon
|
return self._icon
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user