Unconditionally call DomainBlueprints.populate (#80336)

This commit is contained in:
Erik Montnemery 2022-10-14 18:03:43 +02:00 committed by GitHub
parent e01572bc44
commit 4ebf9df901
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 22 deletions

View file

@ -168,11 +168,14 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
# we will create entities before firing EVENT_COMPONENT_LOADED
await async_process_integration_platform_for_component(hass, DOMAIN)
# To register scripts as valid domain for Blueprint
# Register script as valid domain for Blueprint
async_get_blueprints(hass)
if not await _async_process_config(hass, config, component):
await async_get_blueprints(hass).async_populate()
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()
async def reload_service(service: ServiceCall) -> None:
"""Call a service to reload scripts."""
@ -228,13 +231,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
return True
async def _async_process_config(hass, config, component) -> bool:
async def _async_process_config(hass, config, component) -> None:
"""Process script configuration.
Return true, if Blueprints were used.
"""
entities = []
blueprints_used = False
for config_key in extract_domain_configs(config, DOMAIN):
conf: dict[str, dict[str, Any] | BlueprintInputs] = config[config_key]
@ -244,7 +246,6 @@ async def _async_process_config(hass, config, component) -> bool:
raw_config = None
if isinstance(config_block, BlueprintInputs):
blueprints_used = True
blueprint_inputs = config_block
raw_blueprint_inputs = blueprint_inputs.config_with_inputs
@ -271,8 +272,6 @@ async def _async_process_config(hass, config, component) -> bool:
await component.async_add_entities(entities)
return blueprints_used
class ScriptEntity(ToggleEntity, RestoreEntity):
"""Representation of a script entity."""