From bd4ef4b2ff2ec46a7b7372b9532606b3da5feaf7 Mon Sep 17 00:00:00 2001 From: Cris-ET <137873249+Cris-ET@users.noreply.github.com> Date: Mon, 8 Jul 2024 13:03:06 +0200 Subject: [PATCH] Define state_class for Growatt storage entities (#121514) --- .../growatt_server/sensor_types/storage.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/homeassistant/components/growatt_server/sensor_types/storage.py b/homeassistant/components/growatt_server/sensor_types/storage.py index bdad015e95f696..5c6b8321ac49dd 100644 --- a/homeassistant/components/growatt_server/sensor_types/storage.py +++ b/homeassistant/components/growatt_server/sensor_types/storage.py @@ -21,6 +21,7 @@ api_key="eBatDisChargeToday", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), GrowattSensorEntityDescription( key="storage_storage_production_lifetime", @@ -36,6 +37,7 @@ api_key="eacDisChargeToday", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), GrowattSensorEntityDescription( key="storage_load_consumption_today", @@ -43,6 +45,7 @@ api_key="eopDischrToday", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), GrowattSensorEntityDescription( key="storage_load_consumption_lifetime", @@ -58,6 +61,7 @@ api_key="eacChargeToday", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), GrowattSensorEntityDescription( key="storage_charge_storage_lifetime", @@ -73,6 +77,7 @@ api_key="ppv", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), GrowattSensorEntityDescription( key="storage_solar_production_2", @@ -88,6 +93,7 @@ api_key="capacity", native_unit_of_measurement=PERCENTAGE, device_class=SensorDeviceClass.BATTERY, + state_class=SensorStateClass.MEASUREMENT, ), GrowattSensorEntityDescription( key="storage_power_flow", @@ -95,12 +101,14 @@ api_key="pCharge", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), GrowattSensorEntityDescription( key="storage_load_consumption_solar_storage", translation_key="storage_load_consumption_solar_storage", api_key="rateVA", native_unit_of_measurement="VA", + state_class=SensorStateClass.MEASUREMENT, ), GrowattSensorEntityDescription( key="storage_charge_today", @@ -108,6 +116,7 @@ api_key="eChargeToday", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), GrowattSensorEntityDescription( key="storage_import_from_grid", @@ -115,6 +124,7 @@ api_key="pAcInPut", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), GrowattSensorEntityDescription( key="storage_import_from_grid_today", @@ -122,6 +132,7 @@ api_key="eToUserToday", native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, ), GrowattSensorEntityDescription( key="storage_import_from_grid_total", @@ -137,6 +148,7 @@ api_key="outPutPower", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), GrowattSensorEntityDescription( key="storage_grid_voltage", @@ -144,6 +156,7 @@ api_key="vGrid", native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, precision=2, ), GrowattSensorEntityDescription( @@ -152,6 +165,7 @@ api_key="vpv", native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, precision=2, ), GrowattSensorEntityDescription( @@ -160,6 +174,7 @@ api_key="freqOutPut", native_unit_of_measurement=UnitOfFrequency.HERTZ, device_class=SensorDeviceClass.FREQUENCY, + state_class=SensorStateClass.MEASUREMENT, precision=2, ), GrowattSensorEntityDescription( @@ -168,6 +183,7 @@ api_key="outPutVolt", native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, precision=2, ), GrowattSensorEntityDescription( @@ -176,6 +192,7 @@ api_key="freqGrid", native_unit_of_measurement=UnitOfFrequency.HERTZ, device_class=SensorDeviceClass.FREQUENCY, + state_class=SensorStateClass.MEASUREMENT, precision=2, ), GrowattSensorEntityDescription( @@ -184,6 +201,7 @@ api_key="iAcCharge", native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, precision=2, ), GrowattSensorEntityDescription( @@ -192,6 +210,7 @@ api_key="iChargePV1", native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, precision=2, ), GrowattSensorEntityDescription( @@ -200,6 +219,7 @@ api_key="chgCurr", native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, precision=2, ), GrowattSensorEntityDescription( @@ -208,6 +228,7 @@ api_key="outPutCurrent", native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, + state_class=SensorStateClass.MEASUREMENT, precision=2, ), GrowattSensorEntityDescription( @@ -216,6 +237,7 @@ api_key="vBat", native_unit_of_measurement=UnitOfElectricPotential.VOLT, device_class=SensorDeviceClass.VOLTAGE, + state_class=SensorStateClass.MEASUREMENT, precision=2, ), GrowattSensorEntityDescription( @@ -224,6 +246,7 @@ api_key="loadPercent", native_unit_of_measurement=PERCENTAGE, device_class=SensorDeviceClass.BATTERY, + state_class=SensorStateClass.MEASUREMENT, precision=2, ), )