mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Automation: only call executor once when processing config
This commit is contained in:
parent
7ab7edd81c
commit
e18825ba20
@ -280,7 +280,7 @@ class AutomationEntity(ToggleEntity):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def _async_process_config(hass, config, component):
|
def _async_process_config(hass, config, component):
|
||||||
"""Process config and add automations."""
|
"""Process config and add automations."""
|
||||||
success = False
|
entities = []
|
||||||
|
|
||||||
for config_key in extract_domain_configs(config, DOMAIN):
|
for config_key in extract_domain_configs(config, DOMAIN):
|
||||||
conf = config[config_key]
|
conf = config[config_key]
|
||||||
@ -307,13 +307,13 @@ def _async_process_config(hass, config, component):
|
|||||||
async_attach_triggers = partial(
|
async_attach_triggers = partial(
|
||||||
_async_process_trigger, hass, config,
|
_async_process_trigger, hass, config,
|
||||||
config_block.get(CONF_TRIGGER, []), name)
|
config_block.get(CONF_TRIGGER, []), name)
|
||||||
entity = AutomationEntity(name, async_attach_triggers, cond_func,
|
entities.append(AutomationEntity(name, async_attach_triggers,
|
||||||
action, hidden)
|
cond_func, action, hidden))
|
||||||
yield from hass.loop.run_in_executor(
|
|
||||||
None, component.add_entities, [entity])
|
|
||||||
success = True
|
|
||||||
|
|
||||||
return success
|
yield from hass.loop.run_in_executor(
|
||||||
|
None, component.add_entities, entities)
|
||||||
|
|
||||||
|
return len(entities) > 0
|
||||||
|
|
||||||
|
|
||||||
def _async_get_action(hass, config, name):
|
def _async_get_action(hass, config, name):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user