Public Member Functions | |
| 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) |
| str | name (self) |
Public Attributes | |
| attributes | |
| context | |
| entity_id | |
| last_changed | |
| last_reported | |
| last_updated | |
| last_updated_timestamp | |
| object_id | |
| state | |
| state_info | |
Private Member Functions | |
| dict[str, Any] | _as_dict (self) |
| ReadOnlyDict[str, datetime.datetime|Collection[Any]] | _as_read_only_dict (self) |
Static Private Attributes | |
| __slots__ | |
Object to represent a state within the state machine. entity_id: the entity that is represented. state: the state of the entity attributes: extra information on entity and state last_changed: last time the state was changed. last_reported: last time the state was reported. last_updated: last time the state or attributes were changed. context: Context in which it was created domain: Domain of this state. object_id: Object id of this state.
| None homeassistant.core.State.__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 homeassistant.core.State.__repr__ | ( | self | ) |
Return the representation of the states.
Reimplemented in homeassistant.helpers.template.TemplateStateFromEntityId, and homeassistant.helpers.template.TemplateState.
|
private |
|
private |
| CompressedState homeassistant.core.State.as_compressed_state | ( | self | ) |
| bytes homeassistant.core.State.as_compressed_state_json | ( | self | ) |
| ReadOnlyDict[str, datetime.datetime | Collection[Any]] homeassistant.core.State.as_dict | ( | self | ) |
Return a ReadOnlyDict representation of the State. Async friendly. Can be used for JSON serialization. Ensures: state == State.from_dict(state.as_dict())
Reimplemented in homeassistant.components.recorder.models.state.LazyState, and homeassistant.components.recorder.models.legacy.LegacyLazyState.
| bytes homeassistant.core.State.as_dict_json | ( | self | ) |
| None homeassistant.core.State.expire | ( | self | ) |
Mark the state as old. We give up the original reference to the context to ensure the context can be garbage collected by replacing it with a new one with the same id to ensure the old state can still be examined for comparison against the new state. Since we are always going to fire a EVENT_STATE_CHANGED event after we remove a state from the state machine we need to make sure we don't end up holding a reference to the original context since it can never be garbage collected as each event would reference the previous one.
| Self | None homeassistant.core.State.from_dict | ( | cls, | |
| dict[str, Any] | json_dict | ||
| ) |
| json_fragment homeassistant.core.State.json_fragment | ( | self | ) |
| float homeassistant.core.State.last_changed_timestamp | ( | self | ) |
| float homeassistant.core.State.last_reported_timestamp | ( | self | ) |
| str homeassistant.core.State.name | ( | self | ) |
Name of this state.
Reimplemented in homeassistant.helpers.template.TemplateStateBase.