diff --git a/homeassistant/components/workday/calendar.py b/homeassistant/components/workday/calendar.py index 5e72835d742..73788dab369 100644 --- a/homeassistant/components/workday/calendar.py +++ b/homeassistant/components/workday/calendar.py @@ -97,4 +97,8 @@ class WorkdayCalendarEntity(BaseWorkdayEntity, CalendarEntity): self, hass: HomeAssistant, start_date: datetime, end_date: datetime ) -> list[CalendarEvent]: """Get all events in a specific time frame.""" - return self.event_list + return [ + workday + for workday in self.event_list + if start_date.date() <= workday.start <= end_date.date() + ] diff --git a/tests/components/workday/test_calendar.py b/tests/components/workday/test_calendar.py index 1ddf4611b35..132d2008d07 100644 --- a/tests/components/workday/test_calendar.py +++ b/tests/components/workday/test_calendar.py @@ -40,14 +40,15 @@ async def test_holiday_calendar_entity( SERVICE_GET_EVENTS, { "entity_id": "calendar.workday_sensor_calendar", - "end_date_time": dt_util.now() + timedelta(hours=1), + "start_date_time": dt_util.now(), + "end_date_time": dt_util.now() + timedelta(days=10, hours=1), }, blocking=True, return_response=True, ) assert { - "end": "2023-01-01", - "start": "2023-01-02", + "end": "2023-01-02", + "start": "2023-01-01", "summary": "Workday Sensor", } not in response["calendar.workday_sensor_calendar"]["events"] assert {