Return empty when listing statistic_ids for unsupported statistic (#52954)
parent
9cbf88d944
commit
c5556a091e
|
@ -145,8 +145,10 @@ def _get_metadata(hass, session, statistic_ids, statistic_type):
|
|||
)
|
||||
if statistic_type == "mean":
|
||||
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))
|
||||
elif statistic_type is not None:
|
||||
return {}
|
||||
result = execute(baked_query(session).params(statistic_ids=statistic_ids))
|
||||
|
||||
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()
|
||||
assert response["success"]
|
||||
assert response["result"] == [
|
||||
{"statistic_id": "sensor.test", "unit_of_measurement": unit}
|
||||
]
|
||||
assert response["result"] == []
|
||||
|
||||
await client.send_json(
|
||||
{"id": 4, "type": "history/list_statistic_ids", "statistic_type": "mean"}
|
||||
|
|
Loading…
Reference in New Issue