AndroidApps

Tasker PAI series: Google Calendar multi-event fetcher

Disclaimer: The Tasker PAI series is a series of Tasker articles “Provided As Is“. They are marked as such because there’s an above average likelihood that something will break very badly when used by someone else, for whatever reason, and I don’t have the time to fix it for everyone that happens to. Read more here. Articles in this series are only published so that those who know what to do with it have the chance, but questions to these articles will be ignored. 

A lot of people seem to be trying to use Google Calendar data in Tasker, and keep finding an old article of mine that was never meant to show how to do anything other than the specific thing in it, namely fetch the next event.

To try to make something a bit more universal, I sat down and created what’s best described as a Google Calendar plug-in for Tasker. If you feed it your private URL for a calendar, it will chop it up into tiny pieces and sort data into arrays that you can access.

This task is something I created fairly quickly, tested very briefly, and don’t plan on spending more time on. I’m 98% certain that there are better ways of doing this, but it’s not something I’m going to spend time on figuring out, because I have no use for it. I’ve successfully gotten it to work with both all day and more specific tasks (that’s what those If groups are for), but it will probably break for the weirdest of reasons, like time zones, Google Calendar format, device date settings, or who knows what. As such, I will only explain how it’s supposed to work, and beyond that, I can’t help you:

  • Action 5 needs to be edited, and Path needs to be replaced with whatever comes after google.com/ in your private ICAL download link of your calendar. Not a public calendar, not an XML link; pricate ICAL. It should go something like https://www.google.com/calendar/ical/emailstuff/codestuff/basic.ics, where you copy the part in bold into the path field. You find the option in your calendar settings, Calendars, and then whatever calendar you want to use. 
  • Action 9 controls how many events it fetches. %cal1 makes it fetch event 1, %cal2 makes it fetch event 2, %cal(1:10) makes it fetch events 1-10, and so on. %cal() makes it fetch all events and will likely take a while, since the ICAL download seems to contain a bunch of events. Look at the variable array section on this link to understand howto “program” this part.
  • Actions 56-58 are disabled Flash actions you can use to test to see if it works, and also demonstrates how the variables created by this work.

When run, the task will generate 7 local variables for each event. It does so by creating 7 separate arrays. Each array will have one element (variable) for each event you fetch. The arrays are:

  • %caltitle – the title of the event
  • %calstartdate – the start date of the event
  • %calenddate – the end date of the event
  • %calstarttime – the start time of the event
  • %calendtime – the end time of the event
  • %calstartsec – the start date and time in seconds, Tasker standard
  • %calendsec – the end date and time in seconds, Tasker standard

This means that if you have it fetch 3 events, you will have %caltitle1, %caltitle2, %caltitle3, and similarly for all the other arrays. The information for event 1 will be spread across %caltitle1, %calstartdate1, %calenddate1, and so on, and similarly for event 2, 3, etc. Event 200 will have its data in %caltitle200, %calstartdate200, and so on, if you try to fetch that many.

This uses local variables because otherwise it would be too slow. Transfer the data you actually need in intelligent ways if you run this externally.

Download: Calendar_Sorter.tsk.xml

 

Pocketables does not accept targeted advertising, phony guest posts, paid reviews, etc. Help us keep this way with support on Patreon!
Become a patron at Patreon!

Andreas Ødegård

Andreas Ødegård is more interested in aftermarket (and user created) software and hardware than chasing the latest gadgets. His day job as a teacher keeps him interested in education tech and takes up most of his time.

Avatar of Andreas Ødegård