From bcdef4e500298c9d85de3e4f30e577c18679d841 Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Tue, 28 Jan 2020 23:58:43 -0800 Subject: [PATCH] Fix reporting of battery sensor for Tesla (#31232) * Fix reporting of battery sensor for Tesla * Remove try --- homeassistant/components/tesla/__init__.py | 2 ++ homeassistant/components/tesla/binary_sensor.py | 1 + 2 files changed, 3 insertions(+) diff --git a/homeassistant/components/tesla/__init__.py b/homeassistant/components/tesla/__init__.py index 729a449c6ff..3c2a22793db 100644 --- a/homeassistant/components/tesla/__init__.py +++ b/homeassistant/components/tesla/__init__.py @@ -8,6 +8,7 @@ import voluptuous as vol from homeassistant.config_entries import SOURCE_IMPORT from homeassistant.const import ( + ATTR_BATTERY_CHARGING, ATTR_BATTERY_LEVEL, CONF_ACCESS_TOKEN, CONF_PASSWORD, @@ -215,6 +216,7 @@ class TeslaDevice(Entity): attr = self._attributes if self.tesla_device.has_battery(): attr[ATTR_BATTERY_LEVEL] = self.tesla_device.battery_level() + attr[ATTR_BATTERY_CHARGING] = self.tesla_device.battery_charging() return attr @property diff --git a/homeassistant/components/tesla/binary_sensor.py b/homeassistant/components/tesla/binary_sensor.py index 3664cf6252d..8b60cd00163 100644 --- a/homeassistant/components/tesla/binary_sensor.py +++ b/homeassistant/components/tesla/binary_sensor.py @@ -55,3 +55,4 @@ class TeslaBinarySensor(TeslaDevice, BinarySensorDevice): _LOGGER.debug("Updating sensor: %s", self._name) await super().async_update() self._state = self.tesla_device.get_value() + self._attributes = self.tesla_device.attrs