diff --git a/homeassistant/components/solarlog/sensor.py b/homeassistant/components/solarlog/sensor.py index 91e18da1cb2..bb5cf043121 100644 --- a/homeassistant/components/solarlog/sensor.py +++ b/homeassistant/components/solarlog/sensor.py @@ -87,6 +87,7 @@ SOLARLOG_SENSOR_TYPES: tuple[SolarLogCoordinatorSensorEntityDescription, ...] = native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, suggested_display_precision=3, value_fn=lambda data: data.yield_day, ), @@ -105,6 +106,7 @@ SOLARLOG_SENSOR_TYPES: tuple[SolarLogCoordinatorSensorEntityDescription, ...] = native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, suggested_display_precision=3, value_fn=lambda data: data.yield_month, ), @@ -114,6 +116,7 @@ SOLARLOG_SENSOR_TYPES: tuple[SolarLogCoordinatorSensorEntityDescription, ...] = native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, value_fn=lambda data: data.yield_year, ), SolarLogCoordinatorSensorEntityDescription( @@ -140,6 +143,7 @@ SOLARLOG_SENSOR_TYPES: tuple[SolarLogCoordinatorSensorEntityDescription, ...] = native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, suggested_display_precision=3, value_fn=lambda data: data.consumption_day, ), @@ -158,6 +162,7 @@ SOLARLOG_SENSOR_TYPES: tuple[SolarLogCoordinatorSensorEntityDescription, ...] = native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, suggested_display_precision=3, value_fn=lambda data: data.consumption_month, ), @@ -167,6 +172,7 @@ SOLARLOG_SENSOR_TYPES: tuple[SolarLogCoordinatorSensorEntityDescription, ...] = native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, suggested_display_precision=3, value_fn=lambda data: data.consumption_year, ), @@ -193,6 +199,7 @@ SOLARLOG_SENSOR_TYPES: tuple[SolarLogCoordinatorSensorEntityDescription, ...] = translation_key="total_power", native_unit_of_measurement=UnitOfPower.WATT, device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, value_fn=lambda data: data.total_power, ), SolarLogCoordinatorSensorEntityDescription( @@ -255,6 +262,7 @@ INVERTER_SENSOR_TYPES: tuple[SolarLogInverterSensorEntityDescription, ...] = ( native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, suggested_display_precision=3, value_fn=( lambda inverter: None diff --git a/tests/components/solarlog/snapshots/test_sensor.ambr b/tests/components/solarlog/snapshots/test_sensor.ambr index 38356a00de7..32be560fc62 100644 --- a/tests/components/solarlog/snapshots/test_sensor.ambr +++ b/tests/components/solarlog/snapshots/test_sensor.ambr @@ -4,7 +4,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'device_class': None, 'device_id': , @@ -43,6 +45,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'energy', 'friendly_name': 'Inverter 1 Consumption year', + 'state_class': , 'unit_of_measurement': , }), 'context': , @@ -109,7 +112,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'device_class': None, 'device_id': , @@ -148,6 +153,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'energy', 'friendly_name': 'Inverter 2 Consumption year', + 'state_class': , 'unit_of_measurement': , }), 'context': , @@ -370,7 +376,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'device_class': None, 'device_id': , @@ -409,6 +417,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'energy', 'friendly_name': 'solarlog Consumption day', + 'state_class': , 'unit_of_measurement': , }), 'context': , @@ -424,7 +433,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'device_class': None, 'device_id': , @@ -463,6 +474,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'energy', 'friendly_name': 'solarlog Consumption month', + 'state_class': , 'unit_of_measurement': , }), 'context': , @@ -535,7 +547,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'device_class': None, 'device_id': , @@ -574,6 +588,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'energy', 'friendly_name': 'solarlog Consumption year', + 'state_class': , 'unit_of_measurement': , }), 'context': , @@ -697,7 +712,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'device_class': None, 'device_id': , @@ -730,6 +747,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'power', 'friendly_name': 'solarlog Installed peak power', + 'state_class': , 'unit_of_measurement': , }), 'context': , @@ -1152,7 +1170,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'device_class': None, 'device_id': , @@ -1191,6 +1211,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'energy', 'friendly_name': 'solarlog Yield day', + 'state_class': , 'unit_of_measurement': , }), 'context': , @@ -1206,7 +1227,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'device_class': None, 'device_id': , @@ -1245,6 +1268,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'energy', 'friendly_name': 'solarlog Yield month', + 'state_class': , 'unit_of_measurement': , }), 'context': , @@ -1317,7 +1341,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'device_class': None, 'device_id': , @@ -1353,6 +1379,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'energy', 'friendly_name': 'solarlog Yield year', + 'state_class': , 'unit_of_measurement': , }), 'context': ,