Fix targeting all or none entities in service calls (#68513)

* Fix targeting all or none entities in service calls

* Add test
This commit is contained in:
Erik Montnemery
2022-03-22 18:45:27 +01:00
committed by GitHub
parent 43772b3fa9
commit eb068bc850
2 changed files with 22 additions and 3 deletions

View File

@@ -421,6 +421,22 @@ async def test_service_call_entry_id(hass):
assert dict(calls[0].data) == {"entity_id": ["hello.world"]}
@pytest.mark.parametrize("target", ("all", "none"))
async def test_service_call_all_none(hass, target):
"""Test service call targeting all."""
calls = async_mock_service(hass, "test_domain", "test_service")
config = {
"service": "test_domain.test_service",
"target": {"entity_id": target},
}
await service.async_call_from_config(hass, config)
await hass.async_block_till_done()
assert dict(calls[0].data) == {"entity_id": target}
async def test_extract_entity_ids(hass):
"""Test extract_entity_ids method."""
hass.states.async_set("light.Bowl", STATE_ON)