franc6 / ics_calendar

Provides an ICS (icalendar) platform for the Home Assistant calendar
Apache License 2.0
154 stars 23 forks source link

Failed to parse ICS #191

Open GorCed opened 1 week ago

GorCed commented 1 week ago

Home Assistant Setup Please indicate your version of HA and how it is installed.

Version: 5.0.4

Installation Type (put an X between the square brackets for your HA): [] Home Assistant OS [X] Home Assistant OS [] Home Assistant Supervised [] Home Assistant Container [] Home Assistant Core

Hardware platform: [] ARM [X] x86-64

Describe the bug Some of my configured calenders started failing some time ago (about 2 weeks) The calendars are empty and no new entrys gets added.

after some digging I found the "Failed to parse ICS" error in the log.

any ideas of what could be wrong?

{ 2024-11-19 12:07:11.329 DEBUG (MainThread) [custom_components.ics_calendar.calendar] Initializing calendar: SIS_240918 with URL: https://cal.laget.se/SIS_Klubbsida-Ishockey-D2Hockey-16.ics 2024-11-19 12:07:11.333 DEBUG (SyncWorker_23) [custom_components.ics_calendar.calendar] SIS_240918: Update was called 2024-11-19 12:07:11.333 DEBUG (SyncWorker_23) [custom_components.ics_calendar.calendar] SIS_240918: download_calendar start 2024-11-19 12:07:11.333 DEBUG (SyncWorker_23) [custom_components.ics_calendar.calendar] SIS_240918: download_calendar lock acquired 2024-11-19 12:07:11.333 DEBUG (SyncWorker_23) [custom_components.ics_calendar.calendar] SIS_240918: Downloading calendar data from: https://cal.laget.se/SIS_Klubbsida-Ishockey-D2Hockey-16.ics 2024-11-19 12:07:11.333 DEBUG (SyncWorker_23) [custom_components.ics_calendar.calendar] SIS_240918: _download_data start 2024-11-19 12:07:11.405 DEBUG (SyncWorker_23) [custom_components.ics_calendar.calendar] SIS_240918: _download_data done 2024-11-19 12:07:11.405 DEBUG (SyncWorker_23) [custom_components.ics_calendar.calendar] SIS_240918: download_calendar done 2024-11-19 12:07:11.405 DEBUG (SyncWorker_23) [custom_components.ics_calendar.calendar] SIS_240918: Setting calendar content 2024-11-19 12:07:11.458 ERROR (SyncWorker_23) [custom_components.ics_calendar.calendar] update: SIS_240918: Failed to parse ICS! Traceback (most recent call last): File "/config/custom_components/ics_calendar/calendar.py", line 331, in update self.event = self.parser.get_current_event( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ics_calendar/parsers/parser_rie.py", line 118, in get_current_event for event in rie.of(self._calendar).between( ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/recurring_ical_events.py", line 1446, in of return calendar_query( ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/recurring_ical_events.py", line 1290, in init component_adapter.collect_series_from(calendar, self._skip_errors) File "/usr/local/lib/python3.12/site-packages/recurring_ical_events.py", line 1191, in collect_series_from result.append(self._series(components)) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/recurring_ical_events.py", line 610, in init self.compute_span_extension() File "/usr/local/lib/python3.12/site-packages/recurring_ical_events.py", line 615, in compute_span_extension self.recurrence.extend_query_span_by File "/usr/local/lib/python3.12/site-packages/recurring_ical_events.py", line 413, in extend_query_span_by return self.core.extend_query_span_by ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/recurring_ical_events.py", line 259, in cached_property self.dict[name] = value = func(self) ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/recurring_ical_events.py", line 884, in extend_query_span_by subtract_from_start = self.duration ^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/recurring_ical_events.py", line 259, in cached_property self.dict[name] = value = func(self) ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/recurring_ical_events.py", line 865, in duration return self.end - self.start


TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'datetime.date'
2024-11-19 12:07:11.459 DEBUG (SyncWorker_23) [custom_components.ics_calendar.calendar] SIS_240918: No event found!

}
GorCed commented 4 days ago

I've validated the ICS via https://icalendar.org/validator.html and it validates OK. the file is provided by external party and I cant edit it.

any ideas?

franc6 commented 4 days ago

You can try changing the parser to ics. That looks like a bug in the default parser.