1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Find related items scripts/automations (#31293)

* Find related items scripts/automations

* Update manifest
This commit is contained in:
Paulus Schoutsen
2020-01-29 16:19:13 -08:00
committed by GitHub
parent 881437c085
commit 424e15c7a7
11 changed files with 586 additions and 49 deletions

View File

@@ -176,3 +176,37 @@ async def test_if_numeric_state_not_raise_on_unavailable(hass):
hass.states.async_set("sensor.temperature", "unknown")
assert not test(hass)
assert len(logwarn.mock_calls) == 0
async def test_extract_entities():
"""Test extracting entities."""
condition.async_extract_entities(
{
"condition": "and",
"conditions": [
{
"condition": "state",
"entity_id": "sensor.temperature",
"state": "100",
},
{
"condition": "numeric_state",
"entity_id": "sensor.temperature_2",
"below": 110,
},
],
}
) == {"sensor.temperature", "sensor.temperature_2"}
async def test_extract_devices():
"""Test extracting devices."""
condition.async_extract_devices(
{
"condition": "and",
"conditions": [
{"condition": "device", "device_id": "abcd", "domain": "light"},
{"condition": "device", "device_id": "qwer", "domain": "switch"},
],
}
) == {"abcd", "qwer"}