Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local calendar cannot be loaded any more after modifications #105262

Closed
sithmein opened this issue Dec 7, 2023 · 8 comments · Fixed by allenporter/ical#259 or #105462
Closed

Local calendar cannot be loaded any more after modifications #105262

sithmein opened this issue Dec 7, 2023 · 8 comments · Fixed by allenporter/ical#259 or #105462

Comments

@sithmein
Copy link

sithmein commented Dec 7, 2023

The problem

I just modified a local calendar through the UI - setting an event to "daily" - and now the calendar cannot be loaded any more. This is the error in the log:

2023-12-07 22:03:09.651 ERROR (MainThread) [homeassistant.helpers.entity] Update for calendar.office fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/ical/iter.py", line 190, in __iter__
    for value in self._ruleset():
  File "/usr/local/lib/python3.11/site-packages/dateutil/rrule.py", line 1401, in _iter
    while exlist and exlist[0] < ritem:
                     ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/dateutil/rrule.py", line 1338, in __lt__
    return self.dt < other.dt
           ^^^^^^^^^^^^^^^^^^
TypeError: can't compare datetime.datetime to datetime.date

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 696, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 957, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/local_calendar/calendar.py", line 98, in async_update
    if event := next(events, None):
                ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ical/iter.py", line 369, in active_after
    for item in self._iterable:
  File "/usr/local/lib/python3.11/site-packages/ical/iter.py", line 252, in __next__
    self._make_heap()
  File "/usr/local/lib/python3.11/site-packages/ical/iter.py", line 242, in _make_heap
    next_item = next(iterator)
                ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/ical/iter.py", line 222, in __iter__
    for dtvalue in self._recur:
  File "/usr/local/lib/python3.11/site-packages/ical/iter.py", line 193, in __iter__
    raise RecurrenceError(
ical.iter.RecurrenceError: Error evaluating recurrence rule (RulesetIterable(dtstart=2023-12-10, rrule=['DTSTART:20231210T000000\nRRULE:FREQ=WEEKLY;BYDAY=SA,SU'], rdate=[], exdate=[datetime.datetime(2023, 12, 2, 2, 30), datetime.datetime(2023, 12, 3, 2, 30)])): can't compare datetime.datetime to datetime.date

The corresponding ics file is this:

BEGIN:VCALENDAR
PRODID:-//homeassistant.io//local_calendar 1.0//EN
VERSION:2.0
BEGIN:VEVENT
DTSTAMP:20231207T205826
UID:0f43ff9a-94ee-11ed-ad6f-dca63272040c
DTSTART:20230101T023000
DTEND:20230101T180000
SUMMARY:Arbeitszimmer
CREATED:20230115T160249
DESCRIPTION:
LAST-MODIFIED:20231207T205826
RRULE:FREQ=WEEKLY;UNTIL=20231209T023000;BYDAY=SU,SA
EXDATE:20231202T023000
EXDATE:20231203T023000
SEQUENCE:0
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20231203T203804
UID:f67caffa-9567-11ed-8a57-dca63272040c
DTSTART:20230102T013000
DTEND:20230102T183000
SUMMARY:Arbeitszimmer
CREATED:20230116T063526
DESCRIPTION:
LAST-MODIFIED:20231203T203804
RRULE:FREQ=WEEKLY;UNTIL=20231203T013000;BYDAY=MO,TU,WE,TH,FR
SEQUENCE:0
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20231202T153953
UID:094f2550-9129-11ee-8ed3-dca63272040c
DTSTART:20231202T023000
DTEND:20231202T235900
SUMMARY:Arbeitszimmer
CREATED:20230115T160249
DESCRIPTION:
LAST-MODIFIED:20231202T153953
SEQUENCE:1
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20231202T154001
UID:0e863676-9129-11ee-8ed3-dca63272040c
DTSTART:20231203T000000
DTEND:20231203T180000
SUMMARY:Arbeitszimmer
CREATED:20230115T160249
DESCRIPTION:
LAST-MODIFIED:20231202T154001
EXDATE:20231202T023000
SEQUENCE:1
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20231203T203804
UID:dbf0d628-921b-11ee-8ed3-dca63272040c
DTSTART:20231204T003000
DTEND:20231204T173000
SUMMARY:Arbeitszimmer
CREATED:20231203T203804
DESCRIPTION:
LAST-MODIFIED:20231203T203804
RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR
SEQUENCE:0
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20231207T205826
UID:5dcd2cf8-9543-11ee-8ed3-dca63272040c
DTSTART:20231210
DTEND:20231210
SUMMARY:Arbeitszimmer
CREATED:20231207T205826
DESCRIPTION:
LAST-MODIFIED:20231207T205826
RRULE:FREQ=WEEKLY;BYDAY=SU,SA
EXDATE:20231202T023000
EXDATE:20231203T023000
SEQUENCE:0
END:VEVENT
END:VCALENDAR

What version of Home Assistant Core has the issue?

core-2023.11.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Local Calendar

Link to integration documentation on our website

https://www.home-assistant.io/integrations/local_calendar/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

See above.

Additional information

No response

@home-assistant
Copy link

home-assistant bot commented Dec 7, 2023

Hey there @allenporter, mind taking a look at this issue as it has been labeled with an integration (local_calendar) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of local_calendar can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign local_calendar Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


local_calendar documentation
local_calendar source
(message by IssueLinks)

@allenporter
Copy link
Contributor

@sithmein hi can you also include diagnostics for the integration? From the integration '...' menu choose Download diagnostics?

@sithmein
Copy link
Author

Sure. Not that I restored the calendar from backup after it was broken therefore the diagnostics data is from a working state.
config_entry-local_calendar-396ca39ed15d75206651dc8e0ec47a53.json.txt

@allenporter
Copy link
Contributor

allenporter commented Dec 10, 2023

OK, the part i'm having trouble with is the rule for the event with the error message isn't in the ICS file so its hard to match against the original event.

ical.iter.RecurrenceError: Error evaluating recurrence rule (RulesetIterable(dtstart=2023-12-10, rrule=['DTSTART:20231210T000000\nRRULE:FREQ=WEEKLY;BYDAY=SA,SU'], rdate=[], exdate=[datetime.datetime(2023, 12, 2, 2, 30), datetime.datetime(2023, 12, 3, 2, 30)])): can't compare datetime.datetime to datetime.date

Maybe its the last event...

@allenporter
Copy link
Contributor

I'm also a little unsure about the versions having the problem. The error report was for 2023.11.3 though your most recent diagnostic is for 2023.12.0. Can you clarify which home assistant version you are seeing the problem in?

@allenporter
Copy link
Contributor

allenporter commented Dec 10, 2023

I was able to get something like this to happen when changing recurring events back and forth between all day and dated.

config_entry-local_calendar-3bcd8fa21d830bc8d31384f3bbd63692.json.txt

@allenporter
Copy link
Contributor

I've fixed the upstream library, and this can be fixed in the next ical release when it is added to home assistant.

@sithmein
Copy link
Author

Thanks for fixing it so quickly!
(The version differences are because I updated HA shortly after I experienced the bug).

@github-actions github-actions bot locked and limited conversation to collaborators Jan 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants