mirror of
https://github.com/home-assistant/core.git
synced 2025-11-14 05:20:17 +00:00
Add statistics meta data table (#52331)
* Add statistics meta data table * Tweak meta data generation
This commit is contained in:
@@ -951,7 +951,11 @@ async def test_list_statistic_ids(hass, hass_ws_client):
|
||||
hass.states.async_set(
|
||||
"sensor.test",
|
||||
10,
|
||||
attributes={"device_class": "temperature", "state_class": "measurement"},
|
||||
attributes={
|
||||
"device_class": "temperature",
|
||||
"state_class": "measurement",
|
||||
"unit_of_measurement": "°C",
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -962,7 +966,7 @@ async def test_list_statistic_ids(hass, hass_ws_client):
|
||||
await client.send_json({"id": 1, "type": "history/list_statistic_ids"})
|
||||
response = await client.receive_json()
|
||||
assert response["success"]
|
||||
assert response["result"] == {"statistic_ids": []}
|
||||
assert response["result"] == []
|
||||
|
||||
hass.data[recorder.DATA_INSTANCE].do_adhoc_statistics(period="hourly", start=now)
|
||||
await hass.async_add_executor_job(hass.data[recorder.DATA_INSTANCE].block_till_done)
|
||||
@@ -970,25 +974,31 @@ async def test_list_statistic_ids(hass, hass_ws_client):
|
||||
await client.send_json({"id": 2, "type": "history/list_statistic_ids"})
|
||||
response = await client.receive_json()
|
||||
assert response["success"]
|
||||
assert response["result"] == {"statistic_ids": ["sensor.test"]}
|
||||
assert response["result"] == [
|
||||
{"statistic_id": "sensor.test", "unit_of_measurement": "°C"}
|
||||
]
|
||||
|
||||
await client.send_json(
|
||||
{"id": 3, "type": "history/list_statistic_ids", "statistic_type": "dogs"}
|
||||
)
|
||||
response = await client.receive_json()
|
||||
assert response["success"]
|
||||
assert response["result"] == {"statistic_ids": ["sensor.test"]}
|
||||
assert response["result"] == [
|
||||
{"statistic_id": "sensor.test", "unit_of_measurement": "°C"}
|
||||
]
|
||||
|
||||
await client.send_json(
|
||||
{"id": 4, "type": "history/list_statistic_ids", "statistic_type": "mean"}
|
||||
)
|
||||
response = await client.receive_json()
|
||||
assert response["success"]
|
||||
assert response["result"] == {"statistic_ids": ["sensor.test"]}
|
||||
assert response["result"] == [
|
||||
{"statistic_id": "sensor.test", "unit_of_measurement": "°C"}
|
||||
]
|
||||
|
||||
await client.send_json(
|
||||
{"id": 5, "type": "history/list_statistic_ids", "statistic_type": "sum"}
|
||||
)
|
||||
response = await client.receive_json()
|
||||
assert response["success"]
|
||||
assert response["result"] == {"statistic_ids": []}
|
||||
assert response["result"] == []
|
||||
|
||||
Reference in New Issue
Block a user