Allow overriding blueprints on import (#103340)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
af7155df7a
commit
1cfbdd6a5d
6 changed files with 159 additions and 23 deletions
|
@ -1,5 +1,6 @@
|
|||
"""Helpers for automation integration."""
|
||||
from homeassistant.components.blueprint import DomainBlueprints
|
||||
from homeassistant.const import SERVICE_RELOAD
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.singleton import singleton
|
||||
|
||||
|
@ -15,8 +16,15 @@ def _blueprint_in_use(hass: HomeAssistant, blueprint_path: str) -> bool:
|
|||
return len(scripts_with_blueprint(hass, blueprint_path)) > 0
|
||||
|
||||
|
||||
async def _reload_blueprint_scripts(hass: HomeAssistant, blueprint_path: str) -> None:
|
||||
"""Reload all script that rely on a specific blueprint."""
|
||||
await hass.services.async_call(DOMAIN, SERVICE_RELOAD)
|
||||
|
||||
|
||||
@singleton(DATA_BLUEPRINTS)
|
||||
@callback
|
||||
def async_get_blueprints(hass: HomeAssistant) -> DomainBlueprints:
|
||||
"""Get script blueprints."""
|
||||
return DomainBlueprints(hass, DOMAIN, LOGGER, _blueprint_in_use)
|
||||
return DomainBlueprints(
|
||||
hass, DOMAIN, LOGGER, _blueprint_in_use, _reload_blueprint_scripts
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue