Add domain filter support to async_all to match async_entity_ids (#39725)

This avoids copying all the states before applying
the filter
This commit is contained in:
J. Nick Koston 2020-09-06 16:20:32 -05:00 committed by GitHub
parent 19818d96b7
commit 251d8919ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 16 deletions

View file

@ -1454,3 +1454,26 @@ async def test_chained_logging_misses_log_timeout(hass, caplog):
await hass.async_block_till_done()
assert "_task_chain_" not in caplog.text
async def test_async_all(hass):
"""Test async_all."""
hass.states.async_set("switch.link", "on")
hass.states.async_set("light.bowl", "on")
hass.states.async_set("light.frog", "on")
hass.states.async_set("vacuum.floor", "on")
assert {state.entity_id for state in hass.states.async_all()} == {
"switch.link",
"light.bowl",
"light.frog",
"vacuum.floor",
}
assert {state.entity_id for state in hass.states.async_all("light")} == {
"light.bowl",
"light.frog",
}
assert {
state.entity_id for state in hass.states.async_all(["light", "switch"])
} == {"light.bowl", "light.frog", "switch.link"}