Add device class attribute to tado humidity sensor state (#45084)

* add device class attribute to humidity sensor state

* * explict return none
* use const for device class value

* removed unnecessary icon definitions
This commit is contained in:
ErnstEeldert 2021-01-13 13:45:11 +01:00 committed by GitHub
parent ec038bc6ea
commit ff3a1f2050
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,12 @@
import logging
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS
from homeassistant.const import (
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_TEMPERATURE,
PERCENTAGE,
TEMP_CELSIUS,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
@ -126,12 +131,13 @@ class TadoZoneSensor(TadoZoneEntity, Entity):
return None
@property
def icon(self):
"""Icon for the sensor."""
if self.zone_variable == "temperature":
return "mdi:thermometer"
def device_class(self):
"""Return the device class."""
if self.zone_variable == "humidity":
return "mdi:water-percent"
return DEVICE_CLASS_HUMIDITY
if self.zone_variable == "temperature":
return DEVICE_CLASS_TEMPERATURE
return None
@callback
def _async_update_callback(self):