Allow weight to be used as total_increasing state_class for sensors (#108505)
* Allow weight to be used as total_increasing state_class for sensors * Add SensorStateClass.TOTALpull/109744/head
parent
be6399410e
commit
5dfffb0818
|
@ -640,7 +640,11 @@ DEVICE_CLASS_STATE_CLASSES: dict[SensorDeviceClass, set[SensorStateClass]] = {
|
|||
SensorStateClass.TOTAL,
|
||||
SensorStateClass.TOTAL_INCREASING,
|
||||
},
|
||||
SensorDeviceClass.WEIGHT: {SensorStateClass.MEASUREMENT},
|
||||
SensorDeviceClass.WEIGHT: {
|
||||
SensorStateClass.MEASUREMENT,
|
||||
SensorStateClass.TOTAL,
|
||||
SensorStateClass.TOTAL_INCREASING,
|
||||
},
|
||||
SensorDeviceClass.WIND_SPEED: {SensorStateClass.MEASUREMENT},
|
||||
}
|
||||
|
||||
|
|
|
@ -988,6 +988,7 @@ async def test_compile_hourly_sum_statistics_amount(
|
|||
("monetary", "SEK", "SEK", "SEK", None, 1),
|
||||
("gas", "m³", "m³", "m³", "volume", 1),
|
||||
("gas", "ft³", "ft³", "ft³", "volume", 1),
|
||||
("weight", "kg", "kg", "kg", "mass", 1),
|
||||
],
|
||||
)
|
||||
def test_compile_hourly_sum_statistics_amount_reset_every_state_change(
|
||||
|
@ -1457,6 +1458,7 @@ def test_compile_hourly_sum_statistics_negative_state(
|
|||
("monetary", "SEK", "SEK", "SEK", None, 1),
|
||||
("gas", "m³", "m³", "m³", "volume", 1),
|
||||
("gas", "ft³", "ft³", "ft³", "volume", 1),
|
||||
("weight", "kg", "kg", "kg", "mass", 1),
|
||||
],
|
||||
)
|
||||
def test_compile_hourly_sum_statistics_total_no_reset(
|
||||
|
@ -1569,6 +1571,7 @@ def test_compile_hourly_sum_statistics_total_no_reset(
|
|||
("energy", "Wh", "Wh", "Wh", "energy", 1),
|
||||
("gas", "m³", "m³", "m³", "volume", 1),
|
||||
("gas", "ft³", "ft³", "ft³", "volume", 1),
|
||||
("weight", "kg", "kg", "kg", "mass", 1),
|
||||
],
|
||||
)
|
||||
def test_compile_hourly_sum_statistics_total_increasing(
|
||||
|
@ -1679,7 +1682,10 @@ def test_compile_hourly_sum_statistics_total_increasing(
|
|||
"unit_class",
|
||||
"factor",
|
||||
),
|
||||
[("energy", "kWh", "kWh", "kWh", "energy", 1)],
|
||||
[
|
||||
("energy", "kWh", "kWh", "kWh", "energy", 1),
|
||||
("weight", "kg", "kg", "kg", "mass", 1),
|
||||
],
|
||||
)
|
||||
def test_compile_hourly_sum_statistics_total_increasing_small_dip(
|
||||
hass_recorder: Callable[..., HomeAssistant],
|
||||
|
|
Loading…
Reference in New Issue