Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing state class to dsmr sensors #110712

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions homeassistant/components/dsmr/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,15 @@ 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",
translation_key="maximum_demand_current_month",
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",
Expand Down
4 changes: 2 additions & 2 deletions tests/components/dsmr/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,15 +614,15 @@ 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(
"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
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")
Expand Down
Loading