From 7fe4a343f94b40a83bbb37de8254523332e3eb98 Mon Sep 17 00:00:00 2001 From: stegm Date: Wed, 31 Jan 2024 10:37:23 +0100 Subject: [PATCH] Add state_class to Kostal plenticore sensors (#108096) --- .../components/kostal_plenticore/sensor.py | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/kostal_plenticore/sensor.py b/homeassistant/components/kostal_plenticore/sensor.py index 111d497b12899..237a50f85b7fe 100644 --- a/homeassistant/components/kostal_plenticore/sensor.py +++ b/homeassistant/components/kostal_plenticore/sensor.py @@ -82,6 +82,7 @@ class PlenticoreSensorEntityDescription( name="Home Power from Battery", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, formatter="format_round", ), PlenticoreSensorEntityDescription( @@ -232,7 +233,7 @@ class PlenticoreSensorEntityDescription( key="Cycles", name="Battery Cycles", icon="mdi:recycle", - state_class=SensorStateClass.MEASUREMENT, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_round", ), PlenticoreSensorEntityDescription( @@ -324,6 +325,7 @@ class PlenticoreSensorEntityDescription( name="Home Consumption Day", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -332,6 +334,7 @@ class PlenticoreSensorEntityDescription( name="Home Consumption Month", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -340,6 +343,7 @@ class PlenticoreSensorEntityDescription( name="Home Consumption Year", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -357,6 +361,7 @@ class PlenticoreSensorEntityDescription( name="Home Consumption from Battery Day", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -365,6 +370,7 @@ class PlenticoreSensorEntityDescription( name="Home Consumption from Battery Month", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -373,6 +379,7 @@ class PlenticoreSensorEntityDescription( name="Home Consumption from Battery Year", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -390,6 +397,7 @@ class PlenticoreSensorEntityDescription( name="Home Consumption from Grid Day", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -398,6 +406,7 @@ class PlenticoreSensorEntityDescription( name="Home Consumption from Grid Month", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -406,6 +415,7 @@ class PlenticoreSensorEntityDescription( name="Home Consumption from Grid Year", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -423,6 +433,7 @@ class PlenticoreSensorEntityDescription( name="Home Consumption from PV Day", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -431,6 +442,7 @@ class PlenticoreSensorEntityDescription( name="Home Consumption from PV Month", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -439,6 +451,7 @@ class PlenticoreSensorEntityDescription( name="Home Consumption from PV Year", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -456,6 +469,7 @@ class PlenticoreSensorEntityDescription( name="Energy PV1 Day", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -464,6 +478,7 @@ class PlenticoreSensorEntityDescription( name="Energy PV1 Month", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -472,6 +487,7 @@ class PlenticoreSensorEntityDescription( name="Energy PV1 Year", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -489,6 +505,7 @@ class PlenticoreSensorEntityDescription( name="Energy PV2 Day", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -497,6 +514,7 @@ class PlenticoreSensorEntityDescription( name="Energy PV2 Month", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -505,6 +523,7 @@ class PlenticoreSensorEntityDescription( name="Energy PV2 Year", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -522,6 +541,7 @@ class PlenticoreSensorEntityDescription( name="Energy PV3 Day", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -530,6 +550,7 @@ class PlenticoreSensorEntityDescription( name="Energy PV3 Month", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -538,6 +559,7 @@ class PlenticoreSensorEntityDescription( name="Energy PV3 Year", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -556,6 +578,7 @@ class PlenticoreSensorEntityDescription( native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, entity_registry_enabled_default=True, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -564,6 +587,7 @@ class PlenticoreSensorEntityDescription( name="Energy Yield Month", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -572,6 +596,7 @@ class PlenticoreSensorEntityDescription( name="Energy Yield Year", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -589,6 +614,7 @@ class PlenticoreSensorEntityDescription( name="Battery Charge from Grid Day", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -597,6 +623,7 @@ class PlenticoreSensorEntityDescription( name="Battery Charge from Grid Month", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -605,6 +632,7 @@ class PlenticoreSensorEntityDescription( name="Battery Charge from Grid Year", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -622,6 +650,7 @@ class PlenticoreSensorEntityDescription( name="Battery Charge from PV Day", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -630,6 +659,7 @@ class PlenticoreSensorEntityDescription( name="Battery Charge from PV Month", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -638,6 +668,7 @@ class PlenticoreSensorEntityDescription( name="Battery Charge from PV Year", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -655,6 +686,7 @@ class PlenticoreSensorEntityDescription( name="Battery Discharge Day", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -663,6 +695,7 @@ class PlenticoreSensorEntityDescription( name="Battery Discharge Month", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -671,6 +704,7 @@ class PlenticoreSensorEntityDescription( name="Battery Discharge Year", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -688,6 +722,7 @@ class PlenticoreSensorEntityDescription( name="Energy Discharge to Grid Day", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -696,6 +731,7 @@ class PlenticoreSensorEntityDescription( name="Energy Discharge to Grid Month", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription( @@ -704,6 +740,7 @@ class PlenticoreSensorEntityDescription( name="Energy Discharge to Grid Year", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, formatter="format_energy", ), PlenticoreSensorEntityDescription(