diff --git a/homeassistant/components/history/websocket_api.py b/homeassistant/components/history/websocket_api.py index 6eb1fec3416..27e490dd8d4 100644 --- a/homeassistant/components/history/websocket_api.py +++ b/homeassistant/components/history/websocket_api.py @@ -5,7 +5,7 @@ from __future__ import annotations import asyncio from collections.abc import Callable, Iterable, MutableMapping from dataclasses import dataclass -from datetime import datetime as dt +from datetime import datetime as dt, timedelta import logging from typing import Any, cast @@ -564,7 +564,10 @@ async def ws_stream( hass, connection, msg_id, - last_event_time or start_time, + # Add one microsecond so we are outside the window of + # the last event we got from the database since otherwise + # we could fetch the same event twice + (last_event_time or start_time) + timedelta(microseconds=1), subscriptions_setup_complete_time, entity_ids, False, # We don't want the start time state again