Use new DeviceClass and StateClass enums in daikin (#61340)
Co-authored-by: epenet <epenet@users.noreply.github.com>pull/61382/head
parent
8e58ea8397
commit
cfb1002920
|
@ -7,15 +7,12 @@ from dataclasses import dataclass
|
|||
from pydaikin.daikin_base import Appliance
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
PERCENTAGE,
|
||||
|
@ -52,39 +49,39 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
|||
DaikinSensorEntityDescription(
|
||||
key=ATTR_INSIDE_TEMPERATURE,
|
||||
name="Inside Temperature",
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
value_func=lambda device: device.inside_temperature,
|
||||
),
|
||||
DaikinSensorEntityDescription(
|
||||
key=ATTR_OUTSIDE_TEMPERATURE,
|
||||
name="Outside Temperature",
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
value_func=lambda device: device.outside_temperature,
|
||||
),
|
||||
DaikinSensorEntityDescription(
|
||||
key=ATTR_HUMIDITY,
|
||||
name="Humidity",
|
||||
device_class=DEVICE_CLASS_HUMIDITY,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.HUMIDITY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
value_func=lambda device: device.humidity,
|
||||
),
|
||||
DaikinSensorEntityDescription(
|
||||
key=ATTR_TARGET_HUMIDITY,
|
||||
name="Target Humidity",
|
||||
device_class=DEVICE_CLASS_HUMIDITY,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.HUMIDITY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
value_func=lambda device: device.humidity,
|
||||
),
|
||||
DaikinSensorEntityDescription(
|
||||
key=ATTR_TOTAL_POWER,
|
||||
name="Total Power Consumption",
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=POWER_KILO_WATT,
|
||||
value_func=lambda device: round(device.current_total_power_consumption, 2),
|
||||
),
|
||||
|
@ -92,7 +89,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
|||
key=ATTR_COOL_ENERGY,
|
||||
name="Cool Energy Consumption",
|
||||
icon="mdi:snowflake",
|
||||
device_class=DEVICE_CLASS_ENERGY,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
value_func=lambda device: round(device.last_hour_cool_energy_consumption, 2),
|
||||
),
|
||||
|
@ -100,7 +97,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
|||
key=ATTR_HEAT_ENERGY,
|
||||
name="Heat Energy Consumption",
|
||||
icon="mdi:fire",
|
||||
device_class=DEVICE_CLASS_ENERGY,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
value_func=lambda device: round(device.last_hour_heat_energy_consumption, 2),
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue