|
| def | __eq__ (self, other) |
| |
| int | __hash__ (self) |
| |
| None | __init__ (self, str template, HomeAssistant|None hass=None) |
| |
| str | __repr__ (self) |
| |
| Any | async_render (self, TemplateVarsType variables=None, bool parse_result=True, bool limited=False, bool strict=False, Callable[[int, str], None]|None log_fn=None, **Any kwargs) |
| |
| RenderInfo | async_render_to_info (self, TemplateVarsType variables=None, bool strict=False, Callable[[int, str], None]|None log_fn=None, **Any kwargs) |
| |
| bool | async_render_will_timeout (self, float timeout, TemplateVarsType variables=None, bool strict=False, Callable[[int, str], None]|None log_fn=None, **Any kwargs) |
| |
| Any | async_render_with_possible_json_value (self, Any value, Any error_value=_SENTINEL, dict[str, Any]|None variables=None, bool parse_result=False) |
| |
| None | ensure_valid (self) |
| |
| Any | render (self, TemplateVarsType variables=None, bool parse_result=True, bool limited=False, **Any kwargs) |
| |
| def | render_with_possible_json_value (self, value, error_value=_SENTINEL) |
| |
Class to hold a template and manage caching and rendering.
Definition at line 493 of file template.py.
◆ __init__()
| None homeassistant.helpers.template.Template.__init__ |
( |
|
self, |
|
|
str |
template, |
|
|
HomeAssistant | None |
hass = None |
|
) |
| |
Instantiate a template.
Note: A valid hass instance should always be passed in. The hass parameter
will be non optional in Home Assistant Core 2025.10.
Definition at line 511 of file template.py.
◆ __eq__()
| def homeassistant.helpers.template.Template.__eq__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Compare template with another.
Definition at line 855 of file template.py.
◆ __hash__()
| int homeassistant.helpers.template.Template.__hash__ |
( |
|
self | ) |
|
◆ __repr__()
| str homeassistant.helpers.template.Template.__repr__ |
( |
|
self | ) |
|
Representation of Template.
Definition at line 867 of file template.py.
◆ _ensure_compiled()
| jinja2.Template homeassistant.helpers.template.Template._ensure_compiled |
( |
|
self, |
|
|
bool |
limited = False, |
|
|
bool |
strict = False, |
|
|
Callable[[int, str], None] | None |
log_fn = None |
|
) |
| |
|
private |
Bind a template to a specific hass instance.
Definition at line 822 of file template.py.
◆ _env()
◆ _parse_result()
| Any homeassistant.helpers.template.Template._parse_result |
( |
|
self, |
|
|
str |
render_result |
|
) |
| |
|
private |
◆ async_render()
| Any homeassistant.helpers.template.Template.async_render |
( |
|
self, |
|
|
TemplateVarsType |
variables = None, |
|
|
bool |
parse_result = True, |
|
|
bool |
limited = False, |
|
|
bool |
strict = False, |
|
|
Callable[[int, str], None] | None |
log_fn = None, |
|
|
**Any |
kwargs |
|
) |
| |
Render given template.
This method must be run in the event loop.
If limited is True, the template is not allowed to access any function
or filter depending on hass or the state machine.
Definition at line 602 of file template.py.
◆ async_render_to_info()
| RenderInfo homeassistant.helpers.template.Template.async_render_to_info |
( |
|
self, |
|
|
TemplateVarsType |
variables = None, |
|
|
bool |
strict = False, |
|
|
Callable[[int, str], None] | None |
log_fn = None, |
|
|
**Any |
kwargs |
|
) |
| |
Render the template and collect an entity filter.
Definition at line 717 of file template.py.
◆ async_render_will_timeout()
| bool homeassistant.helpers.template.Template.async_render_will_timeout |
( |
|
self, |
|
|
float |
timeout, |
|
|
TemplateVarsType |
variables = None, |
|
|
bool |
strict = False, |
|
|
Callable[[int, str], None] | None |
log_fn = None, |
|
|
**Any |
kwargs |
|
) |
| |
Check to see if rendering a template will timeout during render.
This is intended to check for expensive templates
that will make the system unstable. The template
is rendered in the executor to ensure it does not
tie up the event loop.
This function is not a security control and is only
intended to be used as a safety check when testing
templates.
This method must be run in the event loop.
Definition at line 656 of file template.py.
◆ async_render_with_possible_json_value()
| Any homeassistant.helpers.template.Template.async_render_with_possible_json_value |
( |
|
self, |
|
|
Any |
value, |
|
|
Any |
error_value = _SENTINEL, |
|
|
dict[str, Any] | None |
variables = None, |
|
|
bool |
parse_result = False |
|
) |
| |
Render template with value exposed.
If valid JSON will expose value_json too.
This method must be run in the event loop.
Definition at line 775 of file template.py.
◆ ensure_valid()
| None homeassistant.helpers.template.Template.ensure_valid |
( |
|
self | ) |
|
Return if template is valid.
Definition at line 563 of file template.py.
◆ render()
| Any homeassistant.helpers.template.Template.render |
( |
|
self, |
|
|
TemplateVarsType |
variables = None, |
|
|
bool |
parse_result = True, |
|
|
bool |
limited = False, |
|
|
**Any |
kwargs |
|
) |
| |
Render given template.
If limited is True, the template is not allowed to access any function
or filter depending on hass or the state machine.
Definition at line 579 of file template.py.
◆ render_with_possible_json_value()
| def homeassistant.helpers.template.Template.render_with_possible_json_value |
( |
|
self, |
|
|
|
value, |
|
|
|
error_value = _SENTINEL |
|
) |
| |
Render template with value exposed.
If valid JSON will expose value_json too.
Definition at line 759 of file template.py.
◆ __class__
| homeassistant.helpers.template.Template.__class__ |
|
private |
◆ __slots__
| tuple homeassistant.helpers.template.Template.__slots__ |
|
staticprivate |
Initial value:= (
"__weakref__",
"template",
"hass",
"is_static",
"_compiled_code",
"_compiled",
"_exc_info",
"_limited",
"_strict",
"_log_fn",
"_hash_cache",
"_renders",
)
Definition at line 496 of file template.py.
◆ _compiled
| homeassistant.helpers.template.Template._compiled |
|
private |
◆ _compiled_code
| homeassistant.helpers.template.Template._compiled_code |
|
private |
◆ _exc_info
| homeassistant.helpers.template.Template._exc_info |
|
private |
◆ _limited
| homeassistant.helpers.template.Template._limited |
|
private |
◆ _log_fn
| homeassistant.helpers.template.Template._log_fn |
|
private |
◆ _strict
| homeassistant.helpers.template.Template._strict |
|
private |
◆ hass
| homeassistant.helpers.template.Template.hass |
◆ is_static
| homeassistant.helpers.template.Template.is_static |
◆ template
| homeassistant.helpers.template.Template.template |
The documentation for this class was generated from the following file: