Skip to content

Commit

Permalink
Update StatesManager._oldest_ts when adding pending state
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery committed Nov 27, 2024
1 parent 6ec1340 commit f428958
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/recorder/table_managers/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def add_pending(self, entity_id: str, state: States) -> None:
recorder thread.
"""
self._pending[entity_id] = state
if self._oldest_ts is None and self._pending:
self._oldest_ts = self._pending[next(iter(self._pending))].last_updated_ts

def update_pending_last_reported(
self, state_id: int, last_reported_timestamp: float
Expand All @@ -75,8 +77,6 @@ def post_commit_pending(self) -> None:
This call is not thread-safe and must be called from the
recorder thread.
"""
if self._oldest_ts is None and self._pending:
self._oldest_ts = self._pending[next(iter(self._pending))].last_updated_ts
for entity_id, db_states in self._pending.items():
self._last_committed_id[entity_id] = db_states.state_id
self._pending.clear()
Expand Down

0 comments on commit f428958

Please sign in to comment.