Home Assistant Unofficial Reference 2024.12.1
template.py File Reference

Go to the source code of this file.

Classes

class  homeassistant.helpers.template.AllStates
 
class  homeassistant.helpers.template.DomainStates
 
class  homeassistant.helpers.template.HassLoader
 
class  homeassistant.helpers.template.RenderInfo
 
class  homeassistant.helpers.template.ResultWrapper
 
class  homeassistant.helpers.template.StateTranslated
 
class  homeassistant.helpers.template.Template
 
class  homeassistant.helpers.template.TemplateContextManager
 
class  homeassistant.helpers.template.TemplateEnvironment
 
class  homeassistant.helpers.template.TemplateState
 
class  homeassistant.helpers.template.TemplateStateBase
 
class  homeassistant.helpers.template.TemplateStateFromEntityId
 
class  homeassistant.helpers.template.TupleWrapper
 

Namespaces

 homeassistant.helpers.template
 

Functions

None homeassistant.helpers.template._attach (HomeAssistant hass, Any obj)
 
Any homeassistant.helpers.template._cached_parse_result (str render_result)
 
None homeassistant.helpers.template._collect_state (HomeAssistant hass, str entity_id)
 
DomainStates homeassistant.helpers.template._domain_states (HomeAssistant hass, str name)
 
bool homeassistant.helpers.template._false (str arg)
 
str homeassistant.helpers.template._get_area_name (area_registry.AreaRegistry area_reg, str valid_area_id)
 
HassLoader homeassistant.helpers.template._get_hass_loader (HomeAssistant hass)
 
TemplateState|None homeassistant.helpers.template._get_state (HomeAssistant hass, str entity_id)
 
TemplateState|None homeassistant.helpers.template._get_state_if_valid (HomeAssistant hass, str entity_id)
 
TemplateState|None homeassistant.helpers.template._get_template_state_from_state (HomeAssistant hass, str entity_id, State|None state)
 
bool homeassistant.helpers.template._is_datetime (Any value)
 
bool homeassistant.helpers.template._is_list (Any value)
 
bool homeassistant.helpers.template._is_set (Any value)
 
bool homeassistant.helpers.template._is_string_like (Any value)
 
bool homeassistant.helpers.template._is_tuple (Any value)
 
str|None homeassistant.helpers.template._label_id_or_name (HomeAssistant hass, str label_id_or_name)
 
dict[str, str] homeassistant.helpers.template._load_custom_templates (HomeAssistant hass)
 
Any homeassistant.helpers.template._readonly (*Any args, **Any kwargs)
 
str homeassistant.helpers.template._render_with_context (str template_str, jinja2.Template template, **Any kwargs)
 
State|TemplateState|None homeassistant.helpers.template._resolve_state (HomeAssistant hass, Any entity_id_or_state)
 
Generator[TemplateState] homeassistant.helpers.template._state_generator (HomeAssistant hass, str|None domain)
 
bool|_T homeassistant.helpers.template._T (Any value, _T default)
 
bool|_T|object homeassistant.helpers.template._T (Any value, _T|object default=_SENTINEL)
 
TemplateState homeassistant.helpers.template._template_state (HomeAssistant hass, State state)
 
TemplateState homeassistant.helpers.template._template_state_no_collect (HomeAssistant hass, State state)
 
None homeassistant.helpers.template._to_json_default (Any obj)
 
set[Any] homeassistant.helpers.template._to_set (Any value)
 
def homeassistant.helpers.template._to_tuple (value)
 
bool homeassistant.helpers.template._true (str arg)
 
def homeassistant.helpers.template.add (value, amount, default=_SENTINEL)
 
def homeassistant.helpers.template.arc_cosine (value, default=_SENTINEL)
 
def homeassistant.helpers.template.arc_sine (value, default=_SENTINEL)
 
def homeassistant.helpers.template.arc_tangent (value, default=_SENTINEL)
 
def homeassistant.helpers.template.arc_tangent2 (*args, default=_SENTINEL)
 
Iterable[str] homeassistant.helpers.template.area_devices (HomeAssistant hass, str area_id_or_name)
 
Iterable[str] homeassistant.helpers.template.area_entities (HomeAssistant hass, str area_id_or_name)
 
str|None homeassistant.helpers.template.area_id (HomeAssistant hass, str lookup_value)
 
str|None homeassistant.helpers.template.area_name (HomeAssistant hass, str lookup_value)
 
Iterable[str|None] homeassistant.helpers.template.areas (HomeAssistant hass)
 
Any homeassistant.helpers.template.as_datetime (Any value, Any default=_SENTINEL)
 
timedelta|None homeassistant.helpers.template.as_timedelta (str value)
 
None homeassistant.helpers.template.async_load_custom_templates (HomeAssistant hass)
 
bool homeassistant.helpers.template.async_setup (HomeAssistant hass)
 
None homeassistant.helpers.template.attach (HomeAssistant hass, Any obj)
 
Any homeassistant.helpers.template.average (*Any args, Any default=_SENTINEL)
 
str|bytes homeassistant.helpers.template.base64_decode (str value, str|None encoding="utf-8")
 
str homeassistant.helpers.template.base64_encode (str value)
 
def homeassistant.helpers.template.bitwise_and (first_value, second_value)
 
def homeassistant.helpers.template.bitwise_or (first_value, second_value)
 
def homeassistant.helpers.template.bitwise_xor (first_value, second_value)
 
def homeassistant.helpers.template.closest (hass, *args)
 
def homeassistant.helpers.template.closest_filter (hass, *args)
 
Any homeassistant.helpers.template.config_entry_attr (HomeAssistant hass, str config_entry_id_, str attr_name)
 
str|None homeassistant.helpers.template.config_entry_id (HomeAssistant hass, str entity_id)
 
def homeassistant.helpers.template.cosine (value, default=_SENTINEL)
 
Any homeassistant.helpers.template.device_attr (HomeAssistant hass, str device_or_entity_id, str attr_name)
 
Iterable[str] homeassistant.helpers.template.device_entities (HomeAssistant hass, str _device_id)
 
str|None homeassistant.helpers.template.device_id (HomeAssistant hass, str entity_id_or_device_name)
 
def homeassistant.helpers.template.distance (hass, *args)
 
Iterable[State] homeassistant.helpers.template.expand (HomeAssistant hass, *Any args)
 
def homeassistant.helpers.template.fail_when_undefined (value)
 
Iterable[str] homeassistant.helpers.template.floor_areas (HomeAssistant hass, str floor_id_or_name)
 
str|None homeassistant.helpers.template.floor_id (HomeAssistant hass, Any lookup_value)
 
str|None homeassistant.helpers.template.floor_name (HomeAssistant hass, str lookup_value)
 
Iterable[str|None] homeassistant.helpers.template.floors (HomeAssistant hass)
 
def homeassistant.helpers.template.forgiving_as_timestamp (value, default=_SENTINEL)
 
bool|object homeassistant.helpers.template.forgiving_boolean (Any value)
 
def homeassistant.helpers.template.forgiving_float (value, default=_SENTINEL)
 
def homeassistant.helpers.template.forgiving_float_filter (value, default=_SENTINEL)
 
def homeassistant.helpers.template.forgiving_int (value, default=_SENTINEL, base=10)
 
def homeassistant.helpers.template.forgiving_int_filter (value, default=_SENTINEL, base=10)
 
def homeassistant.helpers.template.forgiving_round (value, precision=0, method="common", default=_SENTINEL)
 
def homeassistant.helpers.template.from_json (value)
 
type homeassistant.helpers.template.gen_result_wrapper (type[dict|list|set] kls)
 
bool homeassistant.helpers.template.has_value (HomeAssistant hass, str entity_id)
 
Any homeassistant.helpers.template.iif (Any value, Any if_true=True, Any if_false=False, Any if_none=_SENTINEL)
 
Iterable[str] homeassistant.helpers.template.integration_entities (HomeAssistant hass, str entry_name)
 
bool homeassistant.helpers.template.is_complex (Any value)
 
bool homeassistant.helpers.template.is_device_attr (HomeAssistant hass, str device_or_entity_id, str attr_name, Any attr_value)
 
bool homeassistant.helpers.template.is_hidden_entity (HomeAssistant hass, str entity_id)
 
def homeassistant.helpers.template.is_number (value)
 
bool homeassistant.helpers.template.is_state (HomeAssistant hass, str entity_id, str|list[str] state)
 
bool homeassistant.helpers.template.is_state_attr (HomeAssistant hass, str entity_id, str name, Any value)
 
bool homeassistant.helpers.template.is_template_string (str maybe_template)
 
dict[str, Any]|None homeassistant.helpers.template.issue (HomeAssistant hass, str domain, str issue_id)
 
dict[tuple[str, str], dict[str, Any]] homeassistant.helpers.template.issues (HomeAssistant hass)
 
Iterable[str] homeassistant.helpers.template.label_areas (HomeAssistant hass, str label_id_or_name)
 
Iterable[str] homeassistant.helpers.template.label_devices (HomeAssistant hass, str label_id_or_name)
 
Iterable[str] homeassistant.helpers.template.label_entities (HomeAssistant hass, str label_id_or_name)
 
str|None homeassistant.helpers.template.label_id (HomeAssistant hass, Any lookup_value)
 
str|None homeassistant.helpers.template.label_name (HomeAssistant hass, str lookup_value)
 
Iterable[str|None] homeassistant.helpers.template.labels (HomeAssistant hass, Any lookup_value=None)
 
def homeassistant.helpers.template.logarithm (value, base=math.e, default=_SENTINEL)
 
type[jinja2.Undefined] homeassistant.helpers.template.make_logging_undefined (bool|None strict, Callable[[int, str], None]|None log_fn)
 
Any homeassistant.helpers.template.median (*Any args, Any default=_SENTINEL)
 
list[Any] homeassistant.helpers.template.merge_response (ServiceResponse value)
 
Any homeassistant.helpers.template.min_max_from_filter (Any builtin_filter, str name)
 
def homeassistant.helpers.template.multiply (value, amount, default=_SENTINEL)
 
datetime homeassistant.helpers.template.now (HomeAssistant hass)
 
def homeassistant.helpers.template.ordinal (value)
 
NoReturn homeassistant.helpers.template.raise_no_default (str function, Any value)
 
def homeassistant.helpers.template.random_every_time (context, values)
 
def homeassistant.helpers.template.regex_findall (value, find="", ignorecase=False)
 
def homeassistant.helpers.template.regex_findall_index (value, find="", index=0, ignorecase=False)
 
def homeassistant.helpers.template.regex_match (value, find="", ignorecase=False)
 
def homeassistant.helpers.template.regex_replace (value="", find="", replace="", ignorecase=False)
 
def homeassistant.helpers.template.regex_search (value, find="", ignorecase=False)
 
Any homeassistant.helpers.template.relative_time (HomeAssistant hass, Any value)
 
Any homeassistant.helpers.template.render_complex (Any value, TemplateVarsType variables=None, bool limited=False, bool parse_result=True)
 
bool homeassistant.helpers.template.result_as_boolean (Any|None template_result)
 
def homeassistant.helpers.template.sine (value, default=_SENTINEL)
 
def homeassistant.helpers.template.slugify (value, separator="_")
 
def homeassistant.helpers.template.square_root (value, default=_SENTINEL)
 
Any homeassistant.helpers.template.state_attr (HomeAssistant hass, str entity_id, str name)
 
Any homeassistant.helpers.template.statistical_mode (*Any args, Any default=_SENTINEL)
 
def homeassistant.helpers.template.strptime (string, fmt, default=_SENTINEL)
 
bytes|None homeassistant.helpers.template.struct_pack (Any|None value, str format_string)
 
Any|None homeassistant.helpers.template.struct_unpack (bytes value, str format_string, int offset=0)
 
def homeassistant.helpers.template.tangent (value, default=_SENTINEL)
 
Any homeassistant.helpers.template.time_since (HomeAssistant hass, Any|datetime value, int precision=1)
 
Any homeassistant.helpers.template.time_until (HomeAssistant hass, Any|datetime value, int precision=1)
 
def homeassistant.helpers.template.timestamp_custom (value, date_format=DATE_STR_FORMAT, local=True, default=_SENTINEL)
 
def homeassistant.helpers.template.timestamp_local (value, default=_SENTINEL)
 
def homeassistant.helpers.template.timestamp_utc (value, default=_SENTINEL)
 
str homeassistant.helpers.template.to_json (Any value, bool ensure_ascii=False, bool pretty_print=False, bool sort_keys=False)
 
datetime homeassistant.helpers.template.today_at (HomeAssistant hass, str time_str="")
 
def homeassistant.helpers.template.urlencode (value)
 
datetime homeassistant.helpers.template.utcnow (HomeAssistant hass)
 
def homeassistant.helpers.template.version (value)
 

Variables

dictionary homeassistant.helpers.template._COLLECTABLE_STATE_ATTRIBUTES
 
 homeassistant.helpers.template._create_template_state_no_collect = partial(TemplateState, collect=False)
 
string homeassistant.helpers.template._HASS_LOADER = "template.hass_loader"
 
 homeassistant.helpers.template._IS_NUMERIC = re.compile(r"^[+-]?(?!0\d)\d*(?:\.\d*)?$")
 
 homeassistant.helpers.template._LOGGER = logging.getLogger(__name__)
 
 homeassistant.helpers.template._NO_HASS_ENV = TemplateEnvironment(None)
 
 homeassistant.helpers.template._regex_cache = lru_cache(maxsize=128)(re.compile)
 
dictionary homeassistant.helpers.template._RESERVED_NAMES
 
 homeassistant.helpers.template._SENTINEL = object()
 
 homeassistant.helpers.template._template_context_manager = TemplateContextManager()
 
int homeassistant.helpers.template.ALL_STATES_RATE_LIMIT = 60
 
int homeassistant.helpers.template.CACHED_TEMPLATE_STATES = 512
 
string homeassistant.helpers.template.DATE_STR_FORMAT = "%Y-%m-%d %H:%M:%S"
 
 homeassistant.helpers.template.default
 
int homeassistant.helpers.template.DOMAIN_STATES_RATE_LIMIT = 1
 
float homeassistant.helpers.template.ENTITY_COUNT_GROWTH_FACTOR = 1.2
 
int homeassistant.helpers.template.EVAL_CACHE_SIZE = 512
 
int homeassistant.helpers.template.MAX_CUSTOM_TEMPLATE_SIZE = 5 * 1024 * 1024
 
int homeassistant.helpers.template.MAX_TEMPLATE_OUTPUT = 256 * 1024
 
tuple homeassistant.helpers.template.ORJSON_PASSTHROUGH_OPTIONS
 
 homeassistant.helpers.template.render_result