Home Assistant Unofficial Reference 2024.12.1
homeassistant.helpers.event.TrackTemplateResultInfo Class Reference

Public Member Functions

None __init__ (self, HomeAssistant hass, Sequence[TrackTemplate] track_templates, TrackTemplateResultListener action, bool has_super_template=False)
 
str __repr__ (self)
 
None async_refresh (self)
 
None async_remove (self)
 
None async_setup (self, bool strict=False, Callable[[int, str], None]|None log_fn=None)
 
dict[str, bool|set[str]] listeners (self)
 

Public Attributes

 hass
 

Private Member Functions

bool _apply_update (self, list[TrackTemplateResult] updates, bool|TrackTemplateResult update, Template template)
 
None _refresh (self, Event[EventStateChangedData]|None event, Iterable[TrackTemplate]|None track_templates=None, bool|None replayed=False)
 
bool|TrackTemplateResult _render_template_if_ready (self, TrackTemplate track_template_, float now, Event[EventStateChangedData]|None event)
 
None _setup_time_listener (self, Template template, bool has_time)
 
None _update_time_listeners (self)
 

Static Private Member Functions

bool _super_template_as_boolean (bool|str|TemplateError result)
 

Private Attributes

 _has_super_template
 
 _job
 
 _rate_limit
 
 _track_state_changes
 
 _track_templates
 

Detailed Description

Handle removal / refresh of tracker.

Definition at line 976 of file event.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.helpers.event.TrackTemplateResultInfo.__init__ (   self,
HomeAssistant  hass,
Sequence[TrackTemplate track_templates,
TrackTemplateResultListener  action,
bool   has_super_template = False 
)
Handle removal / refresh of tracker init.

Definition at line 979 of file event.py.

Member Function Documentation

◆ __repr__()

str homeassistant.helpers.event.TrackTemplateResultInfo.__repr__ (   self)
Return the representation.

Definition at line 1011 of file event.py.

◆ _apply_update()

bool homeassistant.helpers.event.TrackTemplateResultInfo._apply_update (   self,
list[TrackTemplateResult updates,
bool | TrackTemplateResult  update,
Template  template 
)
private
Handle updates of a tracked template.

Definition at line 1203 of file event.py.

◆ _refresh()

None homeassistant.helpers.event.TrackTemplateResultInfo._refresh (   self,
Event[EventStateChangedData] | None  event,
Iterable[TrackTemplate] | None   track_templates = None,
bool | None   replayed = False 
)
private
Refresh the template.

The event is the state_changed event that caused the refresh
to be considered.

track_templates is an optional list of TrackTemplate objects
to refresh.  If not provided, all tracked templates will be
considered.

replayed is True if the event is being replayed because the
rate limit was hit.

Definition at line 1221 of file event.py.

◆ _render_template_if_ready()

bool | TrackTemplateResult homeassistant.helpers.event.TrackTemplateResultInfo._render_template_if_ready (   self,
TrackTemplate  track_template_,
float  now,
Event[EventStateChangedData] | None  event 
)
private
Re-render the template if conditions match.

Returns False if the template was not re-rendered.

Returns True if the template re-rendered and did not
change.

Returns TrackTemplateResult if the template re-render
generates a new result.

Definition at line 1130 of file event.py.

◆ _setup_time_listener()

None homeassistant.helpers.event.TrackTemplateResultInfo._setup_time_listener (   self,
Template  template,
bool  has_time 
)
private

Definition at line 1087 of file event.py.

◆ _super_template_as_boolean()

bool homeassistant.helpers.event.TrackTemplateResultInfo._super_template_as_boolean ( bool | str | TemplateError  result)
staticprivate
Return True if the result is truthy or a TemplateError.

Definition at line 1195 of file event.py.

◆ _update_time_listeners()

None homeassistant.helpers.event.TrackTemplateResultInfo._update_time_listeners (   self)
private

Definition at line 1112 of file event.py.

◆ async_refresh()

None homeassistant.helpers.event.TrackTemplateResultInfo.async_refresh (   self)
Force recalculate the template.

Definition at line 1126 of file event.py.

◆ async_remove()

None homeassistant.helpers.event.TrackTemplateResultInfo.async_remove (   self)
Cancel the listener.

Definition at line 1117 of file event.py.

◆ async_setup()

None homeassistant.helpers.event.TrackTemplateResultInfo.async_setup (   self,
bool   strict = False,
Callable[[int, str], None] | None   log_fn = None 
)
Activation of template tracking.

Definition at line 1015 of file event.py.

◆ listeners()

dict[str, bool | set[str]] homeassistant.helpers.event.TrackTemplateResultInfo.listeners (   self)
State changes that will cause a re-render.

Definition at line 1078 of file event.py.

Member Data Documentation

◆ _has_super_template

homeassistant.helpers.event.TrackTemplateResultInfo._has_super_template
private

Definition at line 991 of file event.py.

◆ _job

homeassistant.helpers.event.TrackTemplateResultInfo._job
private

Definition at line 988 of file event.py.

◆ _rate_limit

homeassistant.helpers.event.TrackTemplateResultInfo._rate_limit
private

Definition at line 1006 of file event.py.

◆ _track_state_changes

homeassistant.helpers.event.TrackTemplateResultInfo._track_state_changes
private

Definition at line 1063 of file event.py.

◆ _track_templates

homeassistant.helpers.event.TrackTemplateResultInfo._track_templates
private

Definition at line 990 of file event.py.

◆ hass

homeassistant.helpers.event.TrackTemplateResultInfo.hass

Definition at line 987 of file event.py.


The documentation for this class was generated from the following file: