Improve statistics issue title (#126851)
parent
e8636670d4
commit
a4ff292231
|
@ -693,15 +693,12 @@ def _update_issues(
|
|||
if state_class is None:
|
||||
# Sensor no longer has a valid state class
|
||||
report_issue(
|
||||
"unsupported_state_class",
|
||||
"state_class_removed",
|
||||
entity_id,
|
||||
{
|
||||
"statistic_id": entity_id,
|
||||
"state_class": state_class,
|
||||
},
|
||||
{"statistic_id": entity_id},
|
||||
)
|
||||
else:
|
||||
clear_issue("unsupported_state_class", entity_id)
|
||||
clear_issue("state_class_removed", entity_id)
|
||||
|
||||
metadata_unit = metadata[1]["unit_of_measurement"]
|
||||
converter = statistics.STATISTIC_UNIT_TO_UNIT_CONVERTER.get(metadata_unit)
|
||||
|
|
|
@ -289,13 +289,13 @@
|
|||
}
|
||||
},
|
||||
"issues": {
|
||||
"state_class_removed": {
|
||||
"title": "{statistic_id} no longer has a state class",
|
||||
"description": ""
|
||||
},
|
||||
"units_changed": {
|
||||
"title": "The unit of {statistic_id} has changed",
|
||||
"description": ""
|
||||
},
|
||||
"unsupported_state_class": {
|
||||
"title": "The state class of {statistic_id} is not supported",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4580,7 +4580,7 @@ async def test_validate_statistics_unit_change_no_device_class(
|
|||
(US_CUSTOMARY_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W"),
|
||||
],
|
||||
)
|
||||
async def test_validate_statistics_unsupported_state_class(
|
||||
async def test_validate_statistics_state_class_removed(
|
||||
hass: HomeAssistant,
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
units,
|
||||
|
@ -4620,15 +4620,12 @@ async def test_validate_statistics_unsupported_state_class(
|
|||
expected = {
|
||||
"sensor.test": [
|
||||
{
|
||||
"data": {
|
||||
"state_class": None,
|
||||
"statistic_id": "sensor.test",
|
||||
},
|
||||
"type": "unsupported_state_class",
|
||||
"data": {"statistic_id": "sensor.test"},
|
||||
"type": "state_class_removed",
|
||||
}
|
||||
],
|
||||
}
|
||||
await assert_validation_result(hass, client, expected, {"unsupported_state_class"})
|
||||
await assert_validation_result(hass, client, expected, {"state_class_removed"})
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -5130,9 +5127,8 @@ async def test_update_statistics_issues(
|
|||
# Let statistics run for one hour, expect issue
|
||||
now = await one_hour_stats(now)
|
||||
expected = {
|
||||
"unsupported_state_class_sensor.test": {
|
||||
"issue_type": "unsupported_state_class",
|
||||
"state_class": None,
|
||||
"state_class_removed_sensor.test": {
|
||||
"issue_type": "state_class_removed",
|
||||
"statistic_id": "sensor.test",
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue