1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Fix entity extraction from Template conditions (#40034)

This commit is contained in:
Franck Nijhof
2020-09-13 22:05:45 +02:00
committed by GitHub
parent 1f8c1f151d
commit cd26384634
2 changed files with 11 additions and 2 deletions

View File

@@ -649,13 +649,16 @@ async def async_validate_condition_config(
@callback
def async_extract_entities(config: ConfigType) -> Set[str]:
def async_extract_entities(config: Union[ConfigType, Template]) -> Set[str]:
"""Extract entities from a condition."""
referenced: Set[str] = set()
to_process = deque([config])
while to_process:
config = to_process.popleft()
if isinstance(config, Template):
continue
condition = config[CONF_CONDITION]
if condition in ("and", "not", "or"):
@@ -674,13 +677,16 @@ def async_extract_entities(config: ConfigType) -> Set[str]:
@callback
def async_extract_devices(config: ConfigType) -> Set[str]:
def async_extract_devices(config: Union[ConfigType, Template]) -> Set[str]:
"""Extract devices from a condition."""
referenced = set()
to_process = deque([config])
while to_process:
config = to_process.popleft()
if isinstance(config, Template):
continue
condition = config[CONF_CONDITION]
if condition in ("and", "not", "or"):