mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Improve statistics issue title (#126851)
This commit is contained in:
parent
cba2daf314
commit
495faf5033
@ -693,15 +693,12 @@ def _update_issues(
|
|||||||
if state_class is None:
|
if state_class is None:
|
||||||
# Sensor no longer has a valid state class
|
# Sensor no longer has a valid state class
|
||||||
report_issue(
|
report_issue(
|
||||||
"unsupported_state_class",
|
"state_class_removed",
|
||||||
entity_id,
|
entity_id,
|
||||||
{
|
{"statistic_id": entity_id},
|
||||||
"statistic_id": entity_id,
|
|
||||||
"state_class": state_class,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
clear_issue("unsupported_state_class", entity_id)
|
clear_issue("state_class_removed", entity_id)
|
||||||
|
|
||||||
metadata_unit = metadata[1]["unit_of_measurement"]
|
metadata_unit = metadata[1]["unit_of_measurement"]
|
||||||
converter = statistics.STATISTIC_UNIT_TO_UNIT_CONVERTER.get(metadata_unit)
|
converter = statistics.STATISTIC_UNIT_TO_UNIT_CONVERTER.get(metadata_unit)
|
||||||
|
@ -289,12 +289,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"issues": {
|
"issues": {
|
||||||
"units_changed": {
|
"state_class_removed": {
|
||||||
"title": "The unit of {statistic_id} has changed",
|
"title": "{statistic_id} no longer has a state class",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"unsupported_state_class": {
|
"units_changed": {
|
||||||
"title": "The state class of {statistic_id} is not supported",
|
"title": "The unit of {statistic_id} has changed",
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4580,7 +4580,7 @@ async def test_validate_statistics_unit_change_no_device_class(
|
|||||||
(US_CUSTOMARY_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W"),
|
(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: HomeAssistant,
|
||||||
hass_ws_client: WebSocketGenerator,
|
hass_ws_client: WebSocketGenerator,
|
||||||
units,
|
units,
|
||||||
@ -4620,15 +4620,12 @@ async def test_validate_statistics_unsupported_state_class(
|
|||||||
expected = {
|
expected = {
|
||||||
"sensor.test": [
|
"sensor.test": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {"statistic_id": "sensor.test"},
|
||||||
"state_class": None,
|
"type": "state_class_removed",
|
||||||
"statistic_id": "sensor.test",
|
|
||||||
},
|
|
||||||
"type": "unsupported_state_class",
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
await assert_validation_result(hass, client, expected, {"unsupported_state_class"})
|
await assert_validation_result(hass, client, expected, {"state_class_removed"})
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@ -5130,9 +5127,8 @@ async def test_update_statistics_issues(
|
|||||||
# Let statistics run for one hour, expect issue
|
# Let statistics run for one hour, expect issue
|
||||||
now = await one_hour_stats(now)
|
now = await one_hour_stats(now)
|
||||||
expected = {
|
expected = {
|
||||||
"unsupported_state_class_sensor.test": {
|
"state_class_removed_sensor.test": {
|
||||||
"issue_type": "unsupported_state_class",
|
"issue_type": "state_class_removed",
|
||||||
"state_class": None,
|
|
||||||
"statistic_id": "sensor.test",
|
"statistic_id": "sensor.test",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user