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