Skip to content
Snippets Groups Projects
Unverified Commit fe5f8e04 authored by Justin Berstler's avatar Justin Berstler Committed by GitHub
Browse files

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.
parent 13f634fa
Branches
Tags
No related merge requests found
...@@ -19,6 +19,7 @@ from homeassistant.const import ( ...@@ -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): ...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment