mirror of
https://github.com/home-assistant/core.git
synced 2025-08-15 10:31:39 +02:00
delete the start time state injector
This commit is contained in:
@@ -611,9 +611,7 @@ def _sorted_states_to_dict(
|
|||||||
axis correctly.
|
axis correctly.
|
||||||
"""
|
"""
|
||||||
field_map = _FIELD_MAP
|
field_map = _FIELD_MAP
|
||||||
state_class: Callable[
|
state_class: Callable[[Row, dict[str, dict[str, Any]]], State | dict[str, Any]]
|
||||||
[Row, dict[str, dict[str, Any]], datetime | None], State | dict[str, Any]
|
|
||||||
]
|
|
||||||
if compressed_state_format:
|
if compressed_state_format:
|
||||||
state_class = row_to_compressed_state
|
state_class = row_to_compressed_state
|
||||||
attr_time = COMPRESSED_STATE_LAST_UPDATED
|
attr_time = COMPRESSED_STATE_LAST_UPDATED
|
||||||
@@ -657,7 +655,7 @@ def _sorted_states_to_dict(
|
|||||||
or split_entity_id(entity_id)[0] in NEED_ATTRIBUTE_DOMAINS
|
or split_entity_id(entity_id)[0] in NEED_ATTRIBUTE_DOMAINS
|
||||||
):
|
):
|
||||||
ent_results.extend(
|
ent_results.extend(
|
||||||
state_class(db_state, attr_cache, None, entity_id=entity_id) # type: ignore[call-arg]
|
state_class(db_state, attr_cache, entity_id=entity_id) # type: ignore[call-arg]
|
||||||
for db_state in group
|
for db_state in group
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
@@ -671,7 +669,7 @@ def _sorted_states_to_dict(
|
|||||||
continue
|
continue
|
||||||
prev_state = first_state.state
|
prev_state = first_state.state
|
||||||
ent_results.append(
|
ent_results.append(
|
||||||
state_class(first_state, attr_cache, None, entity_id=entity_id) # type: ignore[call-arg]
|
state_class(first_state, attr_cache, entity_id=entity_id) # type: ignore[call-arg]
|
||||||
)
|
)
|
||||||
|
|
||||||
state_idx = field_map["state"]
|
state_idx = field_map["state"]
|
||||||
|
@@ -51,7 +51,6 @@ class LazyState(State):
|
|||||||
self,
|
self,
|
||||||
row: Row,
|
row: Row,
|
||||||
attr_cache: dict[str, dict[str, Any]],
|
attr_cache: dict[str, dict[str, Any]],
|
||||||
start_time: datetime | None,
|
|
||||||
entity_id: str | None = None,
|
entity_id: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Init the lazy state."""
|
"""Init the lazy state."""
|
||||||
@@ -59,9 +58,7 @@ class LazyState(State):
|
|||||||
self.entity_id = entity_id or self._row.entity_id
|
self.entity_id = entity_id or self._row.entity_id
|
||||||
self.state = self._row.state or ""
|
self.state = self._row.state or ""
|
||||||
self._attributes: dict[str, Any] | None = None
|
self._attributes: dict[str, Any] | None = None
|
||||||
self._last_updated_ts: float | None = self._row.last_updated_ts or (
|
self._last_updated_ts: float | None = self._row.last_updated_ts
|
||||||
dt_util.utc_to_timestamp(start_time) if start_time else None
|
|
||||||
)
|
|
||||||
self._last_changed_ts: float | None = (
|
self._last_changed_ts: float | None = (
|
||||||
getattr(self._row, "last_changed_ts", None) or self._last_updated_ts
|
getattr(self._row, "last_changed_ts", None) or self._last_updated_ts
|
||||||
)
|
)
|
||||||
@@ -138,7 +135,6 @@ class LazyState(State):
|
|||||||
def row_to_compressed_state(
|
def row_to_compressed_state(
|
||||||
row: Row,
|
row: Row,
|
||||||
attr_cache: dict[str, dict[str, Any]],
|
attr_cache: dict[str, dict[str, Any]],
|
||||||
start_time: datetime | None,
|
|
||||||
entity_id: str | None = None,
|
entity_id: str | None = None,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Convert a database row to a compressed state schema 31 and later."""
|
"""Convert a database row to a compressed state schema 31 and later."""
|
||||||
@@ -146,13 +142,10 @@ def row_to_compressed_state(
|
|||||||
COMPRESSED_STATE_STATE: row.state,
|
COMPRESSED_STATE_STATE: row.state,
|
||||||
COMPRESSED_STATE_ATTRIBUTES: decode_attributes_from_row(row, attr_cache),
|
COMPRESSED_STATE_ATTRIBUTES: decode_attributes_from_row(row, attr_cache),
|
||||||
}
|
}
|
||||||
if start_time:
|
row_last_updated_ts: float = row.last_updated_ts
|
||||||
comp_state[COMPRESSED_STATE_LAST_UPDATED] = dt_util.utc_to_timestamp(start_time)
|
comp_state[COMPRESSED_STATE_LAST_UPDATED] = row_last_updated_ts
|
||||||
else:
|
if row_last_updated_ts != (
|
||||||
row_last_updated_ts: float = row.last_updated_ts
|
row_changed_changed_ts := getattr(row, "last_changed_ts", None)
|
||||||
comp_state[COMPRESSED_STATE_LAST_UPDATED] = row_last_updated_ts
|
):
|
||||||
if row_last_updated_ts != (
|
comp_state[COMPRESSED_STATE_LAST_CHANGED] = row_changed_changed_ts
|
||||||
row_changed_changed_ts := getattr(row, "last_changed_ts", None)
|
|
||||||
):
|
|
||||||
comp_state[COMPRESSED_STATE_LAST_CHANGED] = row_changed_changed_ts
|
|
||||||
return comp_state
|
return comp_state
|
||||||
|
Reference in New Issue
Block a user