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

Add shorthand notation for Template conditions (#39705)

This commit is contained in:
Franck Nijhof
2020-09-06 16:55:06 +02:00
committed by GitHub
parent da9b077c11
commit a3c45a6f89
6 changed files with 87 additions and 43 deletions

View File

@@ -935,7 +935,10 @@ class Script:
await asyncio.shield(self._async_stop(update_state))
async def _async_get_condition(self, config):
config_cache_key = frozenset((k, str(v)) for k, v in config.items())
if isinstance(config, template.Template):
config_cache_key = config.template
else:
config_cache_key = frozenset((k, str(v)) for k, v in config.items())
cond = self._config_cache.get(config_cache_key)
if not cond:
cond = await condition.async_from_config(self._hass, config, False)