Add native units, device classes, and state classes for consumption sensors in Overkiz (#143239)

This commit is contained in:
Mick Vleeshouwer 2025-04-18 22:13:49 +02:00 committed by GitHub
parent d78f63e4d0
commit 4c14184111
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -23,6 +23,7 @@ from homeassistant.const import (
EntityCategory, EntityCategory,
UnitOfEnergy, UnitOfEnergy,
UnitOfPower, UnitOfPower,
UnitOfSpeed,
UnitOfTemperature, UnitOfTemperature,
UnitOfTime, UnitOfTime,
UnitOfVolume, UnitOfVolume,
@ -153,14 +154,23 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
OverkizSensorDescription( OverkizSensorDescription(
key=OverkizState.CORE_FOSSIL_ENERGY_CONSUMPTION, key=OverkizState.CORE_FOSSIL_ENERGY_CONSUMPTION,
name="Fossil energy consumption", name="Fossil energy consumption",
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
), ),
OverkizSensorDescription( OverkizSensorDescription(
key=OverkizState.CORE_GAS_CONSUMPTION, key=OverkizState.CORE_GAS_CONSUMPTION,
name="Gas consumption", name="Gas consumption",
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
device_class=SensorDeviceClass.GAS,
state_class=SensorStateClass.TOTAL_INCREASING,
), ),
OverkizSensorDescription( OverkizSensorDescription(
key=OverkizState.CORE_THERMAL_ENERGY_CONSUMPTION, key=OverkizState.CORE_THERMAL_ENERGY_CONSUMPTION,
name="Thermal energy consumption", name="Thermal energy consumption",
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
), ),
# LightSensor/LuminanceSensor # LightSensor/LuminanceSensor
OverkizSensorDescription( OverkizSensorDescription(
@ -343,6 +353,8 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
name="Sun energy", name="Sun energy",
native_value=lambda value: round(cast(float, value), 2), native_value=lambda value: round(cast(float, value), 2),
icon="mdi:solar-power", icon="mdi:solar-power",
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
# WindSensor/WindSpeedSensor # WindSensor/WindSpeedSensor
@ -351,6 +363,8 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
name="Wind speed", name="Wind speed",
native_value=lambda value: round(cast(float, value), 2), native_value=lambda value: round(cast(float, value), 2),
icon="mdi:weather-windy", icon="mdi:weather-windy",
device_class=SensorDeviceClass.WIND_SPEED,
native_unit_of_measurement=UnitOfSpeed.METERS_PER_SECOND,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
# SmokeSensor/SmokeSensor # SmokeSensor/SmokeSensor