Use device class to isolate tesla battery icon (#37446)

pull/36539/head^2
Chris Talkington 2020-07-04 01:10:04 -05:00 committed by GitHub
parent 4b2ebf5487
commit 6fd8a7a34e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -15,6 +15,7 @@ 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
@ -222,7 +223,10 @@ class TeslaDevice(Entity):
@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(),