diff --git a/homeassistant/components/dsmr/sensor.py b/homeassistant/components/dsmr/sensor.py index 79136a27f1624..56e0af1823ed9 100644 --- a/homeassistant/components/dsmr/sensor.py +++ b/homeassistant/components/dsmr/sensor.py @@ -353,6 +353,7 @@ class DSMRSensorEntityDescription(SensorEntityDescription): obis_reference=obis_references.BELGIUM_CURRENT_AVERAGE_DEMAND, dsmr_versions={"5B"}, device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), DSMRSensorEntityDescription( key="belgium_maximum_demand_current_month", @@ -360,6 +361,7 @@ class DSMRSensorEntityDescription(SensorEntityDescription): obis_reference=obis_references.BELGIUM_MAXIMUM_DEMAND_MONTH, dsmr_versions={"5B"}, device_class=SensorDeviceClass.POWER, + state_class=SensorStateClass.MEASUREMENT, ), DSMRSensorEntityDescription( key="hourly_gas_meter_reading", diff --git a/tests/components/dsmr/test_sensor.py b/tests/components/dsmr/test_sensor.py index 419b562f431a6..c819fa0895583 100644 --- a/tests/components/dsmr/test_sensor.py +++ b/tests/components/dsmr/test_sensor.py @@ -614,7 +614,7 @@ async def test_belgian_meter(hass: HomeAssistant, dsmr_connection_fixture) -> No avg_demand = hass.states.get("sensor.electricity_meter_current_average_demand") assert avg_demand.state == "1.75" assert avg_demand.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.KILO_WATT - assert avg_demand.attributes.get(ATTR_STATE_CLASS) is None + assert avg_demand.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT # check max average demand is parsed correctly max_demand = hass.states.get( @@ -622,7 +622,7 @@ async def test_belgian_meter(hass: HomeAssistant, dsmr_connection_fixture) -> No ) assert max_demand.state == "4.11" assert max_demand.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfPower.KILO_WATT - assert max_demand.attributes.get(ATTR_STATE_CLASS) is None + assert max_demand.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT # check if gas consumption mbus1 is parsed correctly gas_consumption = hass.states.get("sensor.gas_meter_gas_consumption")