Use new enums in tado (#62423)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-20 21:16:12 +01:00 committed by GitHub
parent 369041e0d2
commit 4176cb15f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 23 deletions

View file

@ -1,14 +1,13 @@
"""Support for Tado sensors for each zone."""
import logging
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_TEMPERATURE,
PERCENTAGE,
TEMP_CELSIUS,
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -150,14 +149,14 @@ class TadoHomeSensor(TadoHomeEntity, SensorEntity):
def device_class(self):
"""Return the device class."""
if self.home_variable == "outdoor temperature":
return DEVICE_CLASS_TEMPERATURE
return SensorDeviceClass.TEMPERATURE
return None
@property
def state_class(self):
"""Return the state class."""
if self.home_variable in ["outdoor temperature", "solar percentage"]:
return STATE_CLASS_MEASUREMENT
return SensorStateClass.MEASUREMENT
return None
@callback
@ -261,16 +260,16 @@ class TadoZoneSensor(TadoZoneEntity, SensorEntity):
def device_class(self):
"""Return the device class."""
if self.zone_variable == "humidity":
return DEVICE_CLASS_HUMIDITY
return SensorDeviceClass.HUMIDITY
if self.zone_variable == "temperature":
return DEVICE_CLASS_TEMPERATURE
return SensorDeviceClass.TEMPERATURE
return None
@property
def state_class(self):
"""Return the state class."""
if self.zone_variable in ["ac", "heating", "humidity", "temperature"]:
return STATE_CLASS_MEASUREMENT
return SensorStateClass.MEASUREMENT
return None
@callback