Fix reporting of battery sensor for Tesla (#31232)
* Fix reporting of battery sensor for Tesla * Remove try
This commit is contained in:
parent
61a8618010
commit
bcdef4e500
2 changed files with 3 additions and 0 deletions
|
@ -8,6 +8,7 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT
|
from homeassistant.config_entries import SOURCE_IMPORT
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
ATTR_BATTERY_CHARGING,
|
||||||
ATTR_BATTERY_LEVEL,
|
ATTR_BATTERY_LEVEL,
|
||||||
CONF_ACCESS_TOKEN,
|
CONF_ACCESS_TOKEN,
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
|
@ -215,6 +216,7 @@ class TeslaDevice(Entity):
|
||||||
attr = self._attributes
|
attr = self._attributes
|
||||||
if self.tesla_device.has_battery():
|
if self.tesla_device.has_battery():
|
||||||
attr[ATTR_BATTERY_LEVEL] = self.tesla_device.battery_level()
|
attr[ATTR_BATTERY_LEVEL] = self.tesla_device.battery_level()
|
||||||
|
attr[ATTR_BATTERY_CHARGING] = self.tesla_device.battery_charging()
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -55,3 +55,4 @@ class TeslaBinarySensor(TeslaDevice, BinarySensorDevice):
|
||||||
_LOGGER.debug("Updating sensor: %s", self._name)
|
_LOGGER.debug("Updating sensor: %s", self._name)
|
||||||
await super().async_update()
|
await super().async_update()
|
||||||
self._state = self.tesla_device.get_value()
|
self._state = self.tesla_device.get_value()
|
||||||
|
self._attributes = self.tesla_device.attrs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue