Avoid delaying automation/script startup for sample blueprints (#114277)
Avoid delaying automation/script startup to check if the blueprint folder exists automations and script both populate sample blueprints if none exist The check to see if the blueprint folder exists always had to create an executor job which would delay startup a bit if the executor was busy. Since we do not need the sample blueprints to be populated until the start event, we can run this in a task.pull/114285/head
parent
da78dbb61f
commit
13d6ebaabf
|
@ -298,8 +298,13 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
await _async_process_config(hass, config, component)
|
||||
|
||||
# Add some default blueprints to blueprints/automation, does nothing
|
||||
# if blueprints/automation already exists
|
||||
await async_get_blueprints(hass).async_populate()
|
||||
# if blueprints/automation already exists but still has to create
|
||||
# an executor job to check if the folder exists so we run it in a
|
||||
# separate task to avoid waiting for it to finish setting up
|
||||
# since a tracked task will be waited at the end of startup
|
||||
hass.async_create_task(
|
||||
async_get_blueprints(hass).async_populate(), eager_start=True
|
||||
)
|
||||
|
||||
async def trigger_service_handler(
|
||||
entity: BaseAutomationEntity, service_call: ServiceCall
|
||||
|
|
|
@ -223,8 +223,13 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
await _async_process_config(hass, config, component)
|
||||
|
||||
# Add some default blueprints to blueprints/script, does nothing
|
||||
# if blueprints/script already exists
|
||||
await async_get_blueprints(hass).async_populate()
|
||||
# if blueprints/script already exists but still has to create
|
||||
# an executor job to check if the folder exists so we run it in a
|
||||
# separate task to avoid waiting for it to finish setting up
|
||||
# since a tracked task will be waited at the end of startup
|
||||
hass.async_create_task(
|
||||
async_get_blueprints(hass).async_populate(), eager_start=True
|
||||
)
|
||||
|
||||
async def reload_service(service: ServiceCall) -> None:
|
||||
"""Call a service to reload scripts."""
|
||||
|
|
Loading…
Reference in New Issue