Speed up responding to states being polled via API (#99621)

* Speed up responding to states being polled via API

Switch to using `as_dict_json` to avoid serializing states over and over when the
states api is polled since the mobile app is already building the cache as it also
polls the states via the websocket_api

* Speed up responding to states being polled via API

Switch to using `as_dict_json` to avoid serializing states over and over when the
states api is polled since the mobile app is already building the cache as it also
polls the states via the websocket_api

* fix json

* cover
This commit is contained in:
J. Nick Koston 2023-09-04 15:51:19 -05:00 committed by GitHub
parent 47c20495bd
commit d2a52230ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 11 deletions

View file

@ -575,11 +575,13 @@ async def test_states(
) -> None:
"""Test fetching all states as admin."""
hass.states.async_set("test.entity", "hello")
hass.states.async_set("test.entity2", "hello")
resp = await mock_api_client.get(const.URL_API_STATES)
assert resp.status == HTTPStatus.OK
json = await resp.json()
assert len(json) == 1
assert len(json) == 2
assert json[0]["entity_id"] == "test.entity"
assert json[1]["entity_id"] == "test.entity2"
async def test_states_view_filters(