Add device_class to Tesla sensors (#31231)

This commit is contained in:
Alan Tse 2020-01-29 04:22:04 -08:00 committed by GitHub
parent 64edf2fe33
commit a1e1610a69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,6 +37,7 @@ class TeslaSensor(TeslaDevice, Entity):
self.units = None
self.last_changed_time = None
self.type = sensor_type
self._device_class = tesla_device.device_class
super().__init__(tesla_device, controller, config_entry)
if self.type:
@ -59,6 +60,11 @@ class TeslaSensor(TeslaDevice, Entity):
"""Return the unit_of_measurement of the device."""
return self.units
@property
def device_class(self):
"""Return the device_class of the device."""
return self._device_class
async def async_update(self):
"""Update the state from the sensor."""
_LOGGER.debug("Updating sensor: %s", self._name)