1 """Helpers for template integration."""
11 from .const
import DOMAIN, TEMPLATE_BLUEPRINT_SCHEMA
12 from .template_entity
import TemplateEntity
14 DATA_BLUEPRINTS =
"template_blueprints"
16 LOGGER = logging.getLogger(__name__)
21 """Return all template entity ids that reference the blueprint."""
25 for entity_id, template_entity
in platform.entities.items()
26 if isinstance(template_entity, TemplateEntity)
27 and template_entity.referenced_blueprint == blueprint_path
33 """Return the blueprint the template entity is based on or None."""
36 (template_entity := platform.entities.get(entity_id)), TemplateEntity
38 return template_entity.referenced_blueprint
43 """Return True if any template references the blueprint."""
48 """Reload all templates that rely on a specific blueprint."""
49 await hass.services.async_call(DOMAIN, SERVICE_RELOAD)
52 @singleton(DATA_BLUEPRINTS)
55 """Get template blueprints."""
61 _reload_blueprint_templates,
62 TEMPLATE_BLUEPRINT_SCHEMA,
blueprint.DomainBlueprints async_get_blueprints(HomeAssistant hass)
None _reload_blueprint_templates(HomeAssistant hass, str blueprint_path)
list[str] templates_with_blueprint(HomeAssistant hass, str blueprint_path)
bool _blueprint_in_use(HomeAssistant hass, str blueprint_path)
str|None blueprint_in_template(HomeAssistant hass, str entity_id)