add missing state class to dsmr sensors (#110712)
current_average_demand and maximum_demand_current_month are missing a state class, which gives errors in the statistics tab in HA. So adding them to the sensor.
This commit is contained in:
parent
81199af488
commit
0aaa517217
2 changed files with 4 additions and 2 deletions
|
@ -353,6 +353,7 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
|||
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 @@ SENSORS: tuple[DSMRSensorEntityDescription, ...] = (
|
|||
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",
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Add table
Reference in a new issue