Home Assistant Unofficial Reference 2024.12.1
homeassistant.helpers.template.TemplateStateBase Class Reference
Inheritance diagram for homeassistant.helpers.template.TemplateStateBase:
[legend]
Collaboration diagram for homeassistant.helpers.template.TemplateStateBase:
[legend]

Public Member Functions

bool __eq__ (self, object other)
 
Any __getitem__ (self, str item)
 
None __init__ (self, HomeAssistant hass, bool collect, str entity_id)
 
ReadOnlyDict[str, Any] attributes (self)
 
Context context (self)
 
str domain (self)
 
str entity_id (self)
 
str format_state (self, bool rounded, bool with_unit)
 
datetime last_changed (self)
 
datetime last_reported (self)
 
datetime last_updated (self)
 
str name (self)
 
str object_id (self)
 
str state (self)
 
str state_with_unit (self)
 
- Public Member Functions inherited from homeassistant.core.State
None __init__ (self, str entity_id, str state, Mapping[str, Any]|None attributes=None, datetime.datetime|None last_changed=None, datetime.datetime|None last_reported=None, datetime.datetime|None last_updated=None, Context|None context=None, bool|None validate_entity_id=True, StateInfo|None state_info=None, float|None last_updated_timestamp=None)
 
str __repr__ (self)
 
CompressedState as_compressed_state (self)
 
bytes as_compressed_state_json (self)
 
ReadOnlyDict[str, datetime.datetime|Collection[Any]] as_dict (self)
 
bytes as_dict_json (self)
 
None expire (self)
 
Self|None from_dict (cls, dict[str, Any] json_dict)
 
json_fragment json_fragment (self)
 
float last_changed_timestamp (self)
 
float last_reported_timestamp (self)
 

Private Member Functions

None _collect_state (self)
 

Private Attributes

 _collect
 
 _entity_id
 
 _hass
 

Static Private Attributes

 __delitem__ = _readonly
 
 __setitem__ = _readonly
 
tuple __slots__ = ("_hass", "_collect", "_entity_id", "_state")
 

Additional Inherited Members

- Public Attributes inherited from homeassistant.core.State
 attributes
 
 context
 
 entity_id
 
 last_changed
 
 last_reported
 
 last_updated
 
 last_updated_timestamp
 
 object_id
 
 state
 
 state_info
 

Detailed Description

Class to represent a state object in a template.

Definition at line 1023 of file template.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.helpers.template.TemplateStateBase.__init__ (   self,
HomeAssistant  hass,
bool  collect,
str  entity_id 
)
Initialize template state.

Definition at line 1035 of file template.py.

Member Function Documentation

◆ __eq__()

bool homeassistant.helpers.template.TemplateStateBase.__eq__ (   self,
object  other 
)
Ensure we collect on equality check.

Definition at line 1146 of file template.py.

◆ __getitem__()

Any homeassistant.helpers.template.TemplateStateBase.__getitem__ (   self,
str  item 
)
Return a property as an attribute for jinja.

Definition at line 1048 of file template.py.

◆ _collect_state()

None homeassistant.helpers.template.TemplateStateBase._collect_state (   self)
private

Definition at line 1042 of file template.py.

◆ attributes()

ReadOnlyDict[str, Any] homeassistant.helpers.template.TemplateStateBase.attributes (   self)
Wrap State.attributes.

Definition at line 1076 of file template.py.

◆ context()

Context homeassistant.helpers.template.TemplateStateBase.context (   self)
Wrap State.context.

Definition at line 1100 of file template.py.

◆ domain()

str homeassistant.helpers.template.TemplateStateBase.domain (   self)
Wrap State.domain.

Definition at line 1106 of file template.py.

◆ entity_id()

str homeassistant.helpers.template.TemplateStateBase.entity_id (   self)
Wrap State.entity_id.

Intentionally does not collect state

Definition at line 1062 of file template.py.

◆ format_state()

str homeassistant.helpers.template.TemplateStateBase.format_state (   self,
bool  rounded,
bool  with_unit 
)
Return a formatted version of the state.

Definition at line 1128 of file template.py.

◆ last_changed()

datetime homeassistant.helpers.template.TemplateStateBase.last_changed (   self)
Wrap State.last_changed.

Definition at line 1082 of file template.py.

◆ last_reported()

datetime homeassistant.helpers.template.TemplateStateBase.last_reported (   self)
Wrap State.last_reported.

Definition at line 1088 of file template.py.

◆ last_updated()

datetime homeassistant.helpers.template.TemplateStateBase.last_updated (   self)
Wrap State.last_updated.

Definition at line 1094 of file template.py.

◆ name()

str homeassistant.helpers.template.TemplateStateBase.name (   self)
Wrap State.name.

Reimplemented from homeassistant.core.State.

Definition at line 1118 of file template.py.

◆ object_id()

str homeassistant.helpers.template.TemplateStateBase.object_id (   self)
Wrap State.object_id.

Definition at line 1112 of file template.py.

◆ state()

str homeassistant.helpers.template.TemplateStateBase.state (   self)
Wrap State.state.

Definition at line 1070 of file template.py.

◆ state_with_unit()

str homeassistant.helpers.template.TemplateStateBase.state_with_unit (   self)
Return the state concatenated with the unit if available.

Definition at line 1124 of file template.py.

Member Data Documentation

◆ __delitem__

homeassistant.helpers.template.TemplateStateBase.__delitem__ = _readonly
staticprivate

Definition at line 1031 of file template.py.

◆ __setitem__

homeassistant.helpers.template.TemplateStateBase.__setitem__ = _readonly
staticprivate

Definition at line 1030 of file template.py.

◆ __slots__

tuple homeassistant.helpers.template.TemplateStateBase.__slots__ = ("_hass", "_collect", "_entity_id", "_state")
staticprivate

Definition at line 1026 of file template.py.

◆ _collect

homeassistant.helpers.template.TemplateStateBase._collect
private

Definition at line 1038 of file template.py.

◆ _entity_id

homeassistant.helpers.template.TemplateStateBase._entity_id
private

Definition at line 1039 of file template.py.

◆ _hass

homeassistant.helpers.template.TemplateStateBase._hass
private

Definition at line 1037 of file template.py.


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