uamanager / homebridge-calendar-scheduler

📅 Calendar Scheduler plugin for Homebridge, which allows flexible scheduling of triggers with event progress report using any iCal calendar.
https://www.npmjs.com/package/homebridge-calendar-scheduler
Apache License 2.0
28 stars 1 forks source link

Errors while parsing iCloud calendar #103

Closed rvaneeuwijk closed 1 year ago

rvaneeuwijk commented 1 year ago

Describe The Bug I have just installed the plugin for the first time. The calendar and event sensors are appearing in Apple Home, but they don't seem to work: they don't switch on when an event in the calendar starts. The log on my HOOBS box is showing an error. Am I doing something wrong or is this a bug?

To Reproduce: Install the plugin with the config shown below.

Expected behavior: No errors in log and calendar switch and sensors responding to events in the specified calendar.

Logs: 1/4/2023, 6:22:44 PMCalendar Scheduler Bridge starting 1/4/2023, 6:22:56 PMCalendar Scheduler BridgeLoaded plugin 'homebridge-calendar-scheduler' 1/4/2023, 6:22:56 PMCalendar Scheduler BridgeLoading 1 platforms... 1/4/2023, 6:22:56 PMCalendar Scheduler BridgeCalendarSchedulerFinished initializing platform: CalendarScheduler 1/4/2023, 6:22:57 PMCalendar Scheduler BridgeBridge is running on port 51916. 1/4/2023, 6:22:58 PMCalendar Scheduler BridgeCalendarSchedulerERRORError while updating calendar: Calendar Test at new ParserError (/var/lib/hoobs/calendarschedulerbridge/node_modules/ical.js/build/ical.js:1756:13) at Function.ICAL.parse.parser._handleContentLine (/var/lib/hoobs/calendarschedulerbridge/node_modules/ical.js/build/ical.js:1944:13) at /var/lib/hoobs/calendarschedulerbridge/node_modules/ical.js/build/ical.js:1786:14 at Function.ICAL.parse.parser._eachLine (/var/lib/hoobs/calendarschedulerbridge/node_modules/ical.js/build/ical.js:2260:11) at Object.parser [as parse] (/var/lib/hoobs/calendarschedulerbridge/node_modules/ical.js/build/ical.js:1785:12) at new IcalExpander (/var/lib/hoobs/calendarschedulerbridge/node_modules/ical-expander/index.js:15:26) at Calendar.update (/var/lib/hoobs/calendarschedulerbridge/node_modules/homebridge-calendar-scheduler/src/calendar.ts:52:26) at processTicksAndRejections (node:internal/process/task_queues:96:5) at CalendarHandler._handleCalendarFetchJob (/var/lib/hoobs/calendarschedulerbridge/node_modules/homebridge-calendar-scheduler/src/calendar.handler.ts:85:5) { message: 'invalid line (no token ";" or ":") "Edmonton AB"' }

Plugin Config: { "platform": "CalendarScheduler", "calendars": [ { "calendarName": "Calendar Test", "calendarUrl": "webcal://p39-caldav.icloud.com/published/2/MjY5ODU2NzA2MjY5ODU2NyqwTRTGWxKvAbkzyE7YFRzdSylf20GdTbEAkYDCj7qC", "calendarUpdateInterval": 1, "calendarUpdateButton": true, "calendarTriggerOnAllEvents": true, "calendarEvents": [ { "eventName": "Test" } ] } ] }

Screenshots: Not applicable

Environment:

uamanager commented 1 year ago

Hey, thank you for reporting this!

From what I see in logs, I can tell that something wrong with provided calendar, so that library for parsing calendar data getting error.

Try to use different provider of calendar, for example google, instead of apple.

I won't be able to fix this issue, but you can report it in appropriate repository here

rvaneeuwijk commented 1 year ago

Thanks for looking into this for me. I have changed the calendar URL to a different calendar (still iCloud) and it is running without this error. Still am not able to get the sensors to switch on, but I will submit that as a question. Thanks again.

Bartus78 commented 1 year ago

Thank you for this nice plugin. I seem to experience the same problem with and iCloud calendar.

[1/19/2023, 9:34:21 PM] [homebridge-calendar-scheduler] Error while updating calendar: Haarman agenda at new ParserError (/usr/local/lib/node_modules/homebridge-calendar-scheduler/node_modules/ical.js/build/ical.js:1756:13) at Function.ICAL.parse.parser._handleContentLine (/usr/local/lib/node_modules/homebridge-calendar-scheduler/node_modules/ical.js/build/ical.js:1944:13) at /usr/local/lib/node_modules/homebridge-calendar-scheduler/node_modules/ical.js/build/ical.js:1786:14 at Function.ICAL.parse.parser._eachLine (/usr/local/lib/node_modules/homebridge-calendar-scheduler/node_modules/ical.js/build/ical.js:2260:11) at Object.parser [as parse] (/usr/local/lib/node_modules/homebridge-calendar-scheduler/node_modules/ical.js/build/ical.js:1785:12) at new IcalExpander (/usr/local/lib/node_modules/homebridge-calendar-scheduler/node_modules/ical-expander/index.js:15:26) at Calendar.update (/usr/local/lib/node_modules/homebridge-calendar-scheduler/src/calendar.ts:52:26) at processTicksAndRejections (node:internal/process/task_queues:95:5) at CalendarHandler._handleCalendarFetchJob (/usr/local/lib/node_modules/homebridge-calendar-scheduler/src/calendar.handler.ts:90:5) { message: 'invalid line (no token ";" or ":") "9721AT‎ Groningen"' }

Like @rvaneeuwijk it seems to be an error in the location field of the event.

uamanager commented 1 year ago

@Bartus78 that's pretty interesting. I don't really have control over iCal parsing, but let me see what I can do with this.

uamanager commented 1 year ago

Hey guys, @Bartus78 @rvaneeuwijk can someone provide ical for this event? Or at least help to configure calendar event for reproducing this?

I've tried to add location to event and lots of other options, but got no luck in getting this error.

Bartus78 commented 1 year ago

Thanks for looking into it. I'll send you a link via e-mail.

B

uamanager commented 1 year ago

Hey @Bartus78, Thank you for providing ICS file, it was really helpful!

After reproducing issue and debugging it, I was not sure if I could fix it. But seems like I found pretty good way on how to fix problematic events.

From version 1.8.1, plugin will warn about parsing issues, then try to fix them and finally report if everything went well or not. So you probably will see warnings in your HB console.

Please reply me in this thread if issue still occurs for you or not, so then we can close it or continue to work on it.

@Bartus78 @rvaneeuwijk

Bartus78 commented 1 year ago

Yes, I saw the update. It does work now. However, the error still remains reporting the same error over again:

[1/25/2023, 8:29:14 PM] [homebridge-calendar-scheduler] Error while parsing calendar: Haarman agenda at new ParserError (/usr/local/lib/node_modules/homebridge-calendar-scheduler/node_modules/ical.js/build/ical.js:1756:13) at Function.ICAL.parse.parser._handleContentLine (/usr/local/lib/node_modules/homebridge-calendar-scheduler/node_modules/ical.js/build/ical.js:1944:13) at /usr/local/lib/node_modules/homebridge-calendar-scheduler/node_modules/ical.js/build/ical.js:1786:14 at Function.ICAL.parse.parser._eachLine (/usr/local/lib/node_modules/homebridge-calendar-scheduler/node_modules/ical.js/build/ical.js:2260:11) at Object.parser [as parse] (/usr/local/lib/node_modules/homebridge-calendar-scheduler/node_modules/ical.js/build/ical.js:1785:12) at new IcalExpander (/usr/local/lib/node_modules/homebridge-calendar-scheduler/node_modules/ical-expander/index.js:15:26) at Calendar.update (/usr/local/lib/node_modules/homebridge-calendar-scheduler/src/calendar.ts:54:28) at processTicksAndRejections (node:internal/process/task_queues:95:5) at CalendarHandler._handleCalendarFetchJob (/usr/local/lib/node_modules/homebridge-calendar-scheduler/src/calendar.handler.ts:99:5) { message: 'invalid line (no token ";" or ":") "9721AT‎ Groningen"' } [1/25/2023, 8:29:14 PM] [homebridge-calendar-scheduler] Trying to fix calendar: Haarman agenda [1/25/2023, 8:29:15 PM] [homebridge-calendar-scheduler] Calendar issues fixed: Haarman agenda

But after the fix, exactly the same sequence happens again, 10 minutes later (my update interval)....

uamanager commented 1 year ago

@Bartus78 It's pulling calendar every 10 minutes in your case and after every pull it tries to parse it and as calendar contains errors it shows you them but as warnings.

Do you prefer not to see them until error which cannot be fixed happens?

Bartus78 commented 1 year ago

Well, it would be helpful if I could identify which appointment causes the error. Now I can only see the error with the invalid line, in this case an address. But I as it is now, I cannot see which appointment it is related to, in my calendar with numerous appointments.

uamanager commented 1 year ago

@Bartus78 I've changed logging level to be less annoying :) Let me go through all problematic events and send you their names and dates via email.

uamanager commented 1 year ago

Seems like this issue can be closed. Big thanks to you guys for reporting this and providing help with nailing it down.

Feel free to reopen issue if issue reoccurs.

Stay safe 🇺🇦