Skip to content

Commit f428958

Browse files
committed
Update StatesManager._oldest_ts when adding pending state
1 parent 6ec1340 commit f428958

File tree

1 file changed

+2
-2
lines changed
  • homeassistant/components/recorder/table_managers

1 file changed

+2
-2
lines changed

homeassistant/components/recorder/table_managers/states.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def add_pending(self, entity_id: str, state: States) -> None:
5858
recorder thread.
5959
"""
6060
self._pending[entity_id] = state
61+
if self._oldest_ts is None and self._pending:
62+
self._oldest_ts = self._pending[next(iter(self._pending))].last_updated_ts
6163

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

0 commit comments

Comments
 (0)