Skip to content

Commit

Permalink
Upgrade caldav (fix home-assistant#40127)
Browse files Browse the repository at this point in the history
date_search was deprecated in favour of search which also implements client-side recurring events expansion
  • Loading branch information
daniele-athome committed Jan 14, 2023
1 parent c478e50 commit e01e5b4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
16 changes: 14 additions & 2 deletions homeassistant/components/caldav/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

from datetime import date, datetime, timedelta
from functools import partial
import logging
import re

Expand Down Expand Up @@ -172,7 +173,13 @@ async def async_get_events(
"""Get all events in a specific time frame."""
# Get event list from the current calendar
vevent_list = await hass.async_add_executor_job(
self.calendar.date_search, start_date, end_date
partial(
self.calendar.search,
start=start_date,
end=end_date,
event=True,
expand=True,
)
)
event_list = []
for event in vevent_list:
Expand Down Expand Up @@ -202,7 +209,12 @@ def update(self):

# We have to retrieve the results for the whole day as the server
# won't return events that have already started
results = self.calendar.date_search(start_of_today, start_of_tomorrow)
results = self.calendar.search(
start=start_of_today,
end=start_of_tomorrow,
event=True,
expand=True,
)

# Create new events for each recurrence of an event that happens today.
# For recurring events, some servers return the original event with recurrence rules
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/caldav/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "caldav",
"name": "CalDAV",
"documentation": "https://www.home-assistant.io/integrations/caldav",
"requirements": ["caldav==0.9.1"],
"requirements": ["caldav==0.11.0"],
"codeowners": [],
"iot_class": "cloud_polling",
"loggers": ["caldav", "vobject"]
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ btsmarthub_devicelist==0.2.3
buienradar==1.0.5

# homeassistant.components.caldav
caldav==0.9.1
caldav==0.11.0

# homeassistant.components.circuit
circuit-webhook==1.0.1
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ bthome-ble==2.5.0
buienradar==1.0.5

# homeassistant.components.caldav
caldav==0.9.1
caldav==0.11.0

# homeassistant.components.co2signal
co2signal==0.4.2
Expand Down

0 comments on commit e01e5b4

Please sign in to comment.