diff --git a/homeassistant/components/dsmr/sensor.py b/homeassistant/components/dsmr/sensor.py index e271aac4ee5..99af30b8111 100644 --- a/homeassistant/components/dsmr/sensor.py +++ b/homeassistant/components/dsmr/sensor.py @@ -356,6 +356,22 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = ( device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, ), + DSMRSensorEntityDescription( + key="belgium_current_average_demand", + translation_key="current_average_demand", + obis_reference=obis_references.BELGIUM_CURRENT_AVERAGE_DEMAND, + dsmr_versions={"5B"}, + force_update=True, + device_class=SensorDeviceClass.POWER, + ), + DSMRSensorEntityDescription( + key="belgium_maximum_demand_current_month", + translation_key="maximum_demand_current_month", + obis_reference=obis_references.BELGIUM_MAXIMUM_DEMAND_MONTH, + dsmr_versions={"5B"}, + force_update=True, + device_class=SensorDeviceClass.POWER, + ), DSMRSensorEntityDescription( key="hourly_gas_meter_reading", translation_key="gas_meter_reading", diff --git a/homeassistant/components/dsmr/strings.json b/homeassistant/components/dsmr/strings.json index 7dc44e47a98..5f0568e2905 100644 --- a/homeassistant/components/dsmr/strings.json +++ b/homeassistant/components/dsmr/strings.json @@ -76,6 +76,12 @@ "gas_meter_reading": { "name": "Gas consumption" }, + "current_average_demand": { + "name": "Current average demand" + }, + "maximum_demand_current_month": { + "name": "Maximum demand current month" + }, "instantaneous_active_power_l1_negative": { "name": "Power production phase L1" }, diff --git a/tests/components/dsmr/test_sensor.py b/tests/components/dsmr/test_sensor.py index d734f0a93d5..9c8c4e6fc70 100644 --- a/tests/components/dsmr/test_sensor.py +++ b/tests/components/dsmr/test_sensor.py @@ -480,7 +480,11 @@ async def test_belgian_meter(hass: HomeAssistant, dsmr_connection_fixture) -> No """Test if Belgian meter is correctly parsed.""" (connection_factory, transport, protocol) = dsmr_connection_fixture - from dsmr_parser.obis_references import ELECTRICITY_ACTIVE_TARIFF + from dsmr_parser.obis_references import ( + BELGIUM_CURRENT_AVERAGE_DEMAND, + BELGIUM_MAXIMUM_DEMAND_MONTH, + ELECTRICITY_ACTIVE_TARIFF, + ) from dsmr_parser.objects import CosemObject, MBusObject entry_data = { @@ -503,6 +507,17 @@ async def test_belgian_meter(hass: HomeAssistant, dsmr_connection_fixture) -> No {"value": Decimal(745.695), "unit": "m3"}, ], ), + BELGIUM_CURRENT_AVERAGE_DEMAND: CosemObject( + BELGIUM_CURRENT_AVERAGE_DEMAND, + [{"value": Decimal(1.75), "unit": "kW"}], + ), + BELGIUM_MAXIMUM_DEMAND_MONTH: MBusObject( + BELGIUM_MAXIMUM_DEMAND_MONTH, + [ + {"value": datetime.datetime.fromtimestamp(1551642218)}, + {"value": Decimal(4.11), "unit": "kW"}, + ], + ), ELECTRICITY_ACTIVE_TARIFF: CosemObject( ELECTRICITY_ACTIVE_TARIFF, [{"value": "0001", "unit": ""}] ), @@ -534,6 +549,20 @@ async def test_belgian_meter(hass: HomeAssistant, dsmr_connection_fixture) -> No assert active_tariff.attributes.get(ATTR_STATE_CLASS) is None assert active_tariff.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None + # check current average demand is parsed correctly + 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 + + # check max average demand is parsed correctly + max_demand = hass.states.get( + "sensor.electricity_meter_maximum_demand_current_month" + ) + 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 + # check if gas consumption is parsed correctly gas_consumption = hass.states.get("sensor.gas_meter_gas_consumption") assert gas_consumption.state == "745.695"