Use new enums in tado (#62423)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
369041e0d2
commit
4176cb15f6
2 changed files with 19 additions and 23 deletions
|
@ -2,10 +2,7 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
DEVICE_CLASS_BATTERY,
|
BinarySensorDeviceClass,
|
||||||
DEVICE_CLASS_CONNECTIVITY,
|
|
||||||
DEVICE_CLASS_POWER,
|
|
||||||
DEVICE_CLASS_WINDOW,
|
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -143,9 +140,9 @@ class TadoDeviceBinarySensor(TadoDeviceEntity, BinarySensorEntity):
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
if self.device_variable == "battery state":
|
if self.device_variable == "battery state":
|
||||||
return DEVICE_CLASS_BATTERY
|
return BinarySensorDeviceClass.BATTERY
|
||||||
if self.device_variable == "connection state":
|
if self.device_variable == "connection state":
|
||||||
return DEVICE_CLASS_CONNECTIVITY
|
return BinarySensorDeviceClass.CONNECTIVITY
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
@ -219,15 +216,15 @@ class TadoZoneBinarySensor(TadoZoneEntity, BinarySensorEntity):
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
if self.zone_variable == "early start":
|
if self.zone_variable == "early start":
|
||||||
return DEVICE_CLASS_POWER
|
return BinarySensorDeviceClass.POWER
|
||||||
if self.zone_variable == "link":
|
if self.zone_variable == "link":
|
||||||
return DEVICE_CLASS_CONNECTIVITY
|
return BinarySensorDeviceClass.CONNECTIVITY
|
||||||
if self.zone_variable == "open window":
|
if self.zone_variable == "open window":
|
||||||
return DEVICE_CLASS_WINDOW
|
return BinarySensorDeviceClass.WINDOW
|
||||||
if self.zone_variable == "overlay":
|
if self.zone_variable == "overlay":
|
||||||
return DEVICE_CLASS_POWER
|
return BinarySensorDeviceClass.POWER
|
||||||
if self.zone_variable == "power":
|
if self.zone_variable == "power":
|
||||||
return DEVICE_CLASS_POWER
|
return BinarySensorDeviceClass.POWER
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
"""Support for Tado sensors for each zone."""
|
"""Support for Tado sensors for each zone."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorEntity
|
from homeassistant.components.sensor import (
|
||||||
from homeassistant.config_entries import ConfigEntry
|
SensorDeviceClass,
|
||||||
from homeassistant.const import (
|
SensorEntity,
|
||||||
DEVICE_CLASS_HUMIDITY,
|
SensorStateClass,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
PERCENTAGE,
|
|
||||||
TEMP_CELSIUS,
|
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
|
||||||
|
@ -150,14 +149,14 @@ class TadoHomeSensor(TadoHomeEntity, SensorEntity):
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the device class."""
|
"""Return the device class."""
|
||||||
if self.home_variable == "outdoor temperature":
|
if self.home_variable == "outdoor temperature":
|
||||||
return DEVICE_CLASS_TEMPERATURE
|
return SensorDeviceClass.TEMPERATURE
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state_class(self):
|
def state_class(self):
|
||||||
"""Return the state class."""
|
"""Return the state class."""
|
||||||
if self.home_variable in ["outdoor temperature", "solar percentage"]:
|
if self.home_variable in ["outdoor temperature", "solar percentage"]:
|
||||||
return STATE_CLASS_MEASUREMENT
|
return SensorStateClass.MEASUREMENT
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
@ -261,16 +260,16 @@ class TadoZoneSensor(TadoZoneEntity, SensorEntity):
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the device class."""
|
"""Return the device class."""
|
||||||
if self.zone_variable == "humidity":
|
if self.zone_variable == "humidity":
|
||||||
return DEVICE_CLASS_HUMIDITY
|
return SensorDeviceClass.HUMIDITY
|
||||||
if self.zone_variable == "temperature":
|
if self.zone_variable == "temperature":
|
||||||
return DEVICE_CLASS_TEMPERATURE
|
return SensorDeviceClass.TEMPERATURE
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state_class(self):
|
def state_class(self):
|
||||||
"""Return the state class."""
|
"""Return the state class."""
|
||||||
if self.zone_variable in ["ac", "heating", "humidity", "temperature"]:
|
if self.zone_variable in ["ac", "heating", "humidity", "temperature"]:
|
||||||
return STATE_CLASS_MEASUREMENT
|
return SensorStateClass.MEASUREMENT
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
Loading…
Add table
Reference in a new issue