Add daily energy usage sensor to daikin (#61617)

This commit is contained in:
Tobias Perschon 2022-01-07 14:58:21 +01:00 committed by GitHub
parent 95f8c26e23
commit beed861a19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 4 deletions

View file

@ -33,6 +33,7 @@ from .const import (
ATTR_INSIDE_TEMPERATURE,
ATTR_OUTSIDE_TEMPERATURE,
ATTR_TARGET_HUMIDITY,
ATTR_TOTAL_ENERGY_TODAY,
ATTR_TOTAL_POWER,
)
@ -84,7 +85,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
),
DaikinSensorEntityDescription(
key=ATTR_TOTAL_POWER,
name="Total Power Consumption",
name="Estimated Power Consumption",
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_KILO_WATT,
value_func=lambda device: round(device.current_total_power_consumption, 2),
@ -112,6 +113,14 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
native_unit_of_measurement=FREQUENCY_HERTZ,
value_func=lambda device: device.compressor_frequency,
),
DaikinSensorEntityDescription(
key=ATTR_TOTAL_ENERGY_TODAY,
name="Today's Total Energy Consumption",
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
value_func=lambda device: round(device.today_total_energy_consumption, 2),
),
)
@ -140,6 +149,7 @@ async def async_setup_entry(
sensors.append(ATTR_TOTAL_POWER)
sensors.append(ATTR_COOL_ENERGY)
sensors.append(ATTR_HEAT_ENERGY)
sensors.append(ATTR_TOTAL_ENERGY_TODAY)
if daikin_api.device.support_humidity:
sensors.append(ATTR_HUMIDITY)
sensors.append(ATTR_TARGET_HUMIDITY)