forked from home-assistant/core
Return empty when listing statistic_ids for unsupported statistic (#52954)
This commit is contained in:
@@ -145,8 +145,10 @@ def _get_metadata(hass, session, statistic_ids, statistic_type):
|
|||||||
)
|
)
|
||||||
if statistic_type == "mean":
|
if statistic_type == "mean":
|
||||||
baked_query += lambda q: q.filter(StatisticsMeta.has_mean.isnot(False))
|
baked_query += lambda q: q.filter(StatisticsMeta.has_mean.isnot(False))
|
||||||
if statistic_type == "sum":
|
elif statistic_type == "sum":
|
||||||
baked_query += lambda q: q.filter(StatisticsMeta.has_sum.isnot(False))
|
baked_query += lambda q: q.filter(StatisticsMeta.has_sum.isnot(False))
|
||||||
|
elif statistic_type is not None:
|
||||||
|
return {}
|
||||||
result = execute(baked_query(session).params(statistic_ids=statistic_ids))
|
result = execute(baked_query(session).params(statistic_ids=statistic_ids))
|
||||||
|
|
||||||
metadata_ids = [metadata[0] for metadata in result]
|
metadata_ids = [metadata[0] for metadata in result]
|
||||||
|
@@ -1015,9 +1015,7 @@ async def test_list_statistic_ids(hass, hass_ws_client, units, attributes, unit)
|
|||||||
)
|
)
|
||||||
response = await client.receive_json()
|
response = await client.receive_json()
|
||||||
assert response["success"]
|
assert response["success"]
|
||||||
assert response["result"] == [
|
assert response["result"] == []
|
||||||
{"statistic_id": "sensor.test", "unit_of_measurement": unit}
|
|
||||||
]
|
|
||||||
|
|
||||||
await client.send_json(
|
await client.send_json(
|
||||||
{"id": 4, "type": "history/list_statistic_ids", "statistic_type": "mean"}
|
{"id": 4, "type": "history/list_statistic_ids", "statistic_type": "mean"}
|
||||||
|
Reference in New Issue
Block a user