Skip to content

Commit

Permalink
Use device class to isolate tesla battery icon (home-assistant#37446)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctalkington authored Jul 4, 2020
1 parent 4b2ebf5 commit 6fd8a7a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion homeassistant/components/tesla/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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
Expand Down Expand Up @@ -222,7 +223,10 @@ def unique_id(self) -> str:
@property
def icon(self):
"""Return the icon of the sensor."""
if self.tesla_device.has_battery():
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(),
Expand Down

0 comments on commit 6fd8a7a

Please sign in to comment.