From a1e1610a697efc6b4a25692358742a92f031ff4a Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Wed, 29 Jan 2020 04:22:04 -0800 Subject: [PATCH] Add device_class to Tesla sensors (#31231) --- homeassistant/components/tesla/sensor.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/homeassistant/components/tesla/sensor.py b/homeassistant/components/tesla/sensor.py index 363cdc742d3..9b06828693f 100644 --- a/homeassistant/components/tesla/sensor.py +++ b/homeassistant/components/tesla/sensor.py @@ -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)