mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Use a more detailed battery icon for Tesla cars (#37154)
Use the icon_for_battery_level helper to select a battery icon that indicates charge level and whether or not the battery is actively charging.
This commit is contained in:
parent
13f634fa16
commit
fe5f8e041b
@ -19,6 +19,7 @@ from homeassistant.const import (
|
|||||||
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 (
|
||||||
@ -221,6 +222,12 @@ class TeslaDevice(Entity):
|
|||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""Return the icon of the sensor."""
|
"""Return the icon of the sensor."""
|
||||||
|
if 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
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user