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

Creates recurrent meetings even when some meetings are canceled #398

Closed
mihir8786 opened this issue Dec 22, 2023 · 5 comments · Fixed by #399
Closed

Creates recurrent meetings even when some meetings are canceled #398

mihir8786 opened this issue Dec 22, 2023 · 5 comments · Fixed by #399

Comments

@mihir8786
Copy link

mihir8786 commented Dec 22, 2023

The problem

When there is a recurrent meeting, but one of the meeting from the series is canceled, it still creates that meeting during copy.

Screenshots attached. Original calendar has two meetings for Dec 21 - they are in blue. They were copied correctly. But the pink calendar (copied from blue) has more, which are all recurrent ones in the original calendar but were canceled for Dec 21.

2023-12-21 20 54 37

Version of GAS-ICS-Sync

5.8

Additional information & file uploads

Settings:
var howFrequent = 15;
var onlyFutureEvents = false;
var addEventsToCalendar = true;
var modifyExistingEvents = true;
var removeEventsFromCalendar = true;
var removePastEventsFromCalendar = true;
var addAlerts = "yes";
var addOrganizerToTitle = false;
var descriptionAsTitles = false;
var addCalToTitle = false;
var addAttendees = false;
var defaultAllDayReminder = -1;
var overrideVisibility = "";
var addTasks = false;
var emailSummary = false;
var email = "";
var customEmailSubject = "";
var dateFormat = "YYYY-MM-DD"

ICS string: https://pastebin.com/gaZ6uGRV

@jonas0b1011001
Copy link
Collaborator

From my first impression the input ics is wrong.

Looking at the first event from your screenshot:

BEGIN:VEVENT
DTSTART;TZID=America/Los_Angeles:20231102T070000
DTEND;TZID=America/Los_Angeles:20231102T073000
RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20240620T140000Z;INTERVAL=1;BYDAY=TH
[...]
EXDATE;TZID=America/Los_Angeles:20231220T230000
[...]
SUMMARY:BD - Busy
TRANSP:OPAQUE
END:VEVENT

According to this definition an event instance starting on the 20th at 11pm PST should be excluded.
However the event is taking place on 21th at 07am PST, therefore the EXDATE does not get matched to the actual event instance.

The correct EXDATE would either be
EXDATE;TZID=America/Los_Angeles:20231221T070000
or
EXDATE:20231221T150000Z
but
EXDATE;TZID=America/Los_Angeles:20231220T230000
is wrong in all ways (seems like the exdates are being converted to UTC with the offset being applied the wrong way and the timezone not being removed).

May i ask where your source ics is coming from? Diving this deep into fixing the input might be out of the scope of this script, at least i don't have a quick fix for it.

@mihir8786
Copy link
Author

Thanks for taking a look and totally appreciate if it's out of scope but I thought I would provide more information in case that helps:

The original calendar is my Outlook work calendar: https://pastebin.com/11DKbUme
From there, the script copies to my Google calendar (blue in the screenshot above): https://pastebin.com/gaZ6uGRV

From (work) Outlook to (personal) Google Calendar works as intended. The script does remove recurrent events that were canceled. This is the "blue" calendar in the screenshot above. I was then using this Google Calendar in Home Assistant but started to see these recurrent entries that should have been removed. These entries were only showing up in Home Assistant and not in Google Calendar. To troubleshoot, I am using the script again to copy my Google Calendar (blue) to new Google Calendar (pink) and here's where you see these entries that are neither in the original Outlook nor in the first copied Google Calender (blue).

Here's the link to the second Google Calendar (pink), if it helps: https://pastebin.com/6aMj0DCP

The goal is to run some automations based on the calendar in Home Assistant but because it has unremoved recurrent events, I am running into issues.

Once again, really appreciate the effort on this script and this may be just unsolvable due to Outlook issues.

@jonas0b1011001
Copy link
Collaborator

tl;dr:

Apply the changes from #399.
You will need to either sync your outlook to a fresh google calendar or clear the current target calendar from any events synced by the script prior to the changes (you can do this by syncing an empty calendar to the target calendar, just use "https://pastebin.com/raw/nWRW9ZE1" as source url).

Please be so kind and provide feedback so we can push it to master if all works.


I am using the script again to copy my Google Calendar (blue) to new Google Calendar (pink) and here's where you see these entries that are neither in the original Outlook nor in the first copied Google Calender (blue).

After reading this i assumed the script is actually creating the false exdates somehow. I was able to reproduce the behavior you are describing, however it seems like google is messing up the exdates.

What the script sends to google's API on the first sync:

{[...]
recurrence=[
RRULE:FREQ=WEEKLY;UNTIL=20240620T140000Z;INTERVAL=1;BYDAY=TH;WKST=SU, 
EXDATE;TZID=Pacific Standard Time:20231109T070000,20231116T070000,20231123T070000,20231130T070000,20231207T070000,20231214T070000,20231221T070000,20231228T070000
]}

What we get back from google on the second sync:

BEGIN:VEVENT
[...]
RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20240620T140000Z;INTERVAL=1;BYDAY=TH
EXDATE;TZID=America/Los_Angeles:20231108T230000
EXDATE;TZID=America/Los_Angeles:20231115T230000
EXDATE;TZID=America/Los_Angeles:20231122T230000
EXDATE;TZID=America/Los_Angeles:20231129T230000
EXDATE;TZID=America/Los_Angeles:20231206T230000
EXDATE;TZID=America/Los_Angeles:20231213T230000
EXDATE;TZID=America/Los_Angeles:20231220T230000
EXDATE;TZID=America/Los_Angeles:20231227T230000
[...]
END:VEVENT

Now the interesting part

Changing the exdates in the source from sync one to UTC actually fixes the issue!
Output Sync1:
recurrence=[RRULE:FREQ=WEEKLY;UNTIL=20240620T140000Z;INTERVAL=1;BYDAY=TH;WKST=SU, EXDATE:20231109T150000Z,20231116T150000Z,20231123T150000Z,20231130T150000Z,20231207T150000Z,20231214T150000Z,20231221T150000Z,20231228T150000Z]

Input Sync2:

RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20240620T140000Z;INTERVAL=1;BYDAY=TH
EXDATE;TZID=America/Los_Angeles:20231109T070000
EXDATE;TZID=America/Los_Angeles:20231116T070000
EXDATE;TZID=America/Los_Angeles:20231123T070000
EXDATE;TZID=America/Los_Angeles:20231130T070000
EXDATE;TZID=America/Los_Angeles:20231207T070000
EXDATE;TZID=America/Los_Angeles:20231214T070000
EXDATE;TZID=America/Los_Angeles:20231221T070000
EXDATE;TZID=America/Los_Angeles:20231228T070000

And the best part: it even stays fixed if you would add a third step (sync the GCal from step 2 to another GCal), therefore exdate being in UTC can't be the actual solution. Google does not know "Pacific Standard Time", therefore treats it as UTC and converts it to "America/Los_Angeles". This is how the wrong exdates in calendar 2 are created.

Solution: We need to replace timezones in recurrence parameters aswell, code is at the beginning of this post.

@mihir8786
Copy link
Author

Thank you so much! The changes in #399 worked! Sent a little thank you to your PayPal for this and all the work on this script!

@jonas0b1011001 jonas0b1011001 linked a pull request Dec 22, 2023 that will close this issue
@jonas0b1011001
Copy link
Collaborator

Thank you, glad we figured it out!

jonas0b1011001 added a commit that referenced this issue May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants