[GUIDE][Difficulty: Advanced] Read Google Calendar Events for the Day

Search This thread

MishaalRahman

Retired Editor in Chief
Nov 2, 2015
1,043
2,142
www.xda-developers.com
Thank you MishaalRahman,

I have read numerous solutions to pulling events from Google Calendar, but none so elegant. I have recently discovered phones and more recently discovered Tasker. My skills are quite rusty but with the help others (you included) I am finding my way. This is a wonderful resource.

As some have already pointed out, this is a great task to include in a wake-up profile. However, not all of us work or sleep on a regular schedule. I remember the 'good ole days' when I could get by on just two jobs.

A moving time segment from 'now' to 'set_length' would be ideal. I think I can work that out. But Event location (address) to pass to Google Maps or Waze as a destination is a topic for which I haven't found much information. Do you (or anyone else) have any suggestions?

Yes, simply pull the location by doing Test App --> Calendar Location, store that in a variable (just like we're doing with time, event title, and calendar name) then when you're done you can navigate to that location by using a Google Maps Navigation intent: https://stackoverflow.com/questions...ogle-maps-directions-via-an-intent-on-android
 

Tepes4

Senior Member
Jun 14, 2008
304
26
Xiaomi Mi 10T / 10T Pro
OnePlus 9
Hey @MishaalRahman,

thanks for this great post. I have followed the steps but I'm always getting "You have no events today", when I have set a couple of events and some reminders. I have tried with my main calendar, I have tried with other calendars such as Work and Reminders but always the same result. Any ideas?

Thanks in advance,
Tepes4

Edit: Sorry about that, it seems that it was a sync issue after all. After manually syncing the calendar, it works. But can it work with the Reminders functionality of google calendar?
 
Last edited:
  • Like
Reactions: MishaalRahman

EnIXmA

Senior Member
Feb 16, 2012
1,445
259
Mississauga, on
I am using Google calender, in step 6 what should I can be “my calender”to? Google calendar or leave it as it is?
Should I change something in step 5 too?

Keeps saying you have no events today
 
Last edited:
@EnIXmA

The note at the end of the numbered instructions reads in part, "IF YOU IMPORT THIS, YOU MUST EDIT ACTION #6 (THE IF ACTION) AND CHANGE *MYCALENDAR*. REPLACE "MYCALENDAR" WITH THE NAME OF THE CALENDAR YOU WANT TO PULL FROM."

I'm sure you recall that when you linked to the various Google services (including calendar), you were asked for the email address of your Gmail account. In this case, you would enter (without the quotes), "*[email protected]*" to replace "*MYCALENDAR*" in step 6.

As an aside, I set AutoSync off and run a profile that turns it on for a few minutes every hour. When AutosSync is turned on it attempts to sync all enabled accounts. So when I am ready to use this profile for my morning agenda, I turn on AutoSync about 5 minutes prior to running 'GetEvents'.

I have taken this nifty task and am modifying it to retrieve my 'next' event. If there is a location stored in the event, that information will be passed to Maps for navigation (per the VERY useful tip from the OP located in post 21). I only need to sync Calendar if I have added an event that will occur within the hour. Keeping AutoSync off is just another way to save battery.

Hope this helps.

I am using Google calender, in step 6 what should I can be “my calender”to? Google calendar or leave it as it is?
Should I change something in step 5 too?

Keeps saying you have no events today
 
Last edited:
  • Like
Reactions: vizdak and EnIXmA

EnIXmA

Senior Member
Feb 16, 2012
1,445
259
Mississauga, on
@EnIXmA

The note at the end of the numbered instructions reads in part, "IF YOU IMPORT THIS, YOU MUST EDIT ACTION #6 (THE IF ACTION) AND CHANGE *MYCALENDAR*. REPLACE "MYCALENDAR" WITH THE NAME OF THE CALENDAR YOU WANT TO PULL FROM."

I'm sure you recall that when you linked to the various Google services (including calendar), you were asked for the email address of your Gmail account. In this case, you would enter (without the quotes), "*[email protected]*" to replace "*MYCALENDAR*" in step 6.

As an aside, I set AutoSync off and run a profile that turns it on for a few minutes every hour. When AutosSync is turned on it attempts to sync all enabled accounts. So when I am ready to use this profile for my morning agenda, I turn on AutoSync about 5 minutes prior to running 'GetEvents'.

I have taken this nifty task and am modifying it to retrieve my 'next' event. If there is a location stored in the event, that information will be passed to Maps for navigation (per the VERY useful tip from the OP located in post 21). I only need to sync Calendar if I have added an event that will occur within the hour. Keeping AutoSync off is just another way to save battery.

Hope this helps.
Thnx man.. Working fine now
 
  • Like
Reactions: barry123

schorsch.funke

Senior Member
Dec 10, 2011
180
77
Swisttal
Hi all,
is there any way to test other calendar than Google calendar? I'm using a private calendar with davdroid. The calendar app I use is acalendar.
With the test app method i'm can test only the Google one.

Many thanks, Georg

Gesendet von meinem SM-G900F mit Tapatalk
 
Last edited:

schorsch.funke

Senior Member
Dec 10, 2011
180
77
Swisttal
Hi all,
is there any way to test other calendar than Google calendar? I'm using a private calendar with davdroid. The calendar app I use is acalendar.
With the test app method i'm can test only the Google one.

Many thanks, Georg

Gesendet von meinem SM-G900F mit Tapatalk
I have solved the problem. I had not clear the entries in the Google Calendar before I switch to a private DAVdroid Calendar

Gesendet von meinem SM-G900F mit Tapatalk
 

githyanki

Senior Member
Mar 11, 2009
1,659
879
Edmonton
I have been working on modifying these tasks to meet my requirements, and would like to share the results with everyone.
I had a few issues with the way the original calendar task handled overlapping events. All day events and items that overlapped, sometimes either showed the wrong time, or showed multiple times, or did not show at all. Almost made me wake up late one morning.
For all day events, I I set a variable at the beginning to no, and the first event that was not a all day event I set it to yes. from then on, all day events were ignored.
For overlapping events, right before the if loop that parsed all the events I set up a for loop to pass overlapping events to the for loop one at a time. This created the need to rearrange the doublecheck variable, so I appended each event as it went through the for loop and had to search through the variable separately before the loop.

I also split it into two profiles, one that runs in the evening and will set my alarm for work in the morning, and another that runs in the morning that notify's me verbally and with a popup.

I can write a whole Guide if anyone wants to see what I did so they can incorporate it, but for now I just attached the profiles. Let me know if anyone's interested!
 

Attachments

  • Calendar_Today.prf.xml
    9.1 KB · Views: 511
  • Calendar_Tomorrow.prf.xml
    11.5 KB · Views: 317
Last edited:

magarlick

Member
Jul 29, 2011
5
0
Can't get it to work

Hi. Thanks for posting this. But I can't get it to work. I've set the calendar name to my Gmail email address. Is that right? This is my main calendar. But it just tells me I have no events when I clearly do. And yes the calendar has been synced.

Thank you
 

Hern

Member
Mar 8, 2009
5
0
Winchester
I have football fixtures on my phone and two events are at the same time today and it only announced one of them.

So I looked at Githyanki's post:

I have been working on modifying these tasks to meet my requirements, and would like to share the results with everyone.
I had a few issues with the way the original calendar task handled overlapping events. All day events and items that overlapped, sometimes either showed the wrong time, or showed multiple times, or did not show at all. Almost made me wake up late one morning.
For all day events, I I set a variable at the beginning to no, and the first event that was not a all day event I set it to yes. from then on, all day events were ignored.
For overlapping events, right before the if loop that parsed all the events I set up a for loop to pass overlapping events to the for loop one at a time. This created the need to rearrange the doublecheck variable, so I appended each event as it went through the for loop and had to search through the variable separately before the loop.

I also split it into two profiles, one that runs in the evening and will set my alarm for work in the morning, and another that runs in the morning that notify's me verbally and with a popup.

I can write a whole Guide if anyone wants to see what I did so they can incorporate it, but for now I just attached the profiles. Let me know if anyone's interested!


And it announced both of them! I love the pop up text idea too! I have two events today and the text inside the box was too large for the box, but the 4 events tomorrow all fit inside the pop up box. Weird.

I use Alarmpad dismiss to launch the original task, so if I can modify Githyanki's tomorrow profile to announce 'todays' events when I wake up that would be awesome.

Something for me to play with today.
 
Last edited:

githyanki

Senior Member
Mar 11, 2009
1,659
879
Edmonton
I have football fixtures on my phone and two events are at the same time today and it only announced one of them.

So I looked at Githyanki's post:




And it announced both of them! I love the pop up text idea too! I have two events today and the text inside the box was too large for the box, but the 4 events tomorrow all fit inside the pop up box. Weird.

I use Alarmpad dismiss to launch the original task, so if I can modify Githyanki's tomorrow profile to announce 'todays' events when I wake up that would be awesome.

Something for me to play with today.
The text size is not adjustable unfortunately. Looks funny in landscape mode also if you have too many events.
I posted one that did today's events also....
 
  • Like
Reactions: Hern

Javi22

Senior Member
Feb 26, 2011
2,041
188
Madrid
This profile is awesome, thanks.!

Just wondering if there's any way it read reminders too? (they also appear in Google calendar)

Sent from my Nexus 5X using Tapatalk
 

vickylahkarbytes

Senior Member
Dec 25, 2013
68
13
You're a busy person, and you've decided to organize your busy life by placing all your events on Google Calendar. If this describes you, then you might like to know that you can query Calendar for its events and set it up to notify you however you want. This means you don't have to open the app or even display a widget if you want to see what your events for the day are. Here's how.

This guide is based heavily off of the work of redditor CallMeLucky but written to be more friendly and with more documentation. Credits for the implementation go to him.

Prerequisites

  • Google Calendar

Instructions

  1. Create a new task, and name it "Get Events."
  2. Variables --> Variable Convert. Convert %DATE, set the Function to "Date Time to Seconds" and Store Result In %date.
  3. Variables --> Variable Set. Name %schedstart and set To
    Code:
    %date + (60*60*6)
    This sets the start time to 6AM in the morning. If you want to make it earlier, change the 6 to a different number. CHECK DO MATHS!
  4. Variables --> Variable Set. Name %schedend and set To
    Code:
    %date + (60*60*24)
    This sets the end time to midnight. CHECK DO MATHS!
  5. App --> Test App. Type "Calendar Title", Data %schedstart, Store Result In %event. Set the Label to "TEST NEXT EVENT." This is querying Google Calendar using the time to see if there's an event at that time.
  6. App --> Test App. Type "Calendar Calendar", Data %schedstart, Store Result In %calendar. This is querying the calendar to see, if there's an event, which calendar it belongs to.
  7. Task --> If. If %event(#) neq 0 AND %event1 !~ %doubleevent AND %calendar1 ~ *MYCALENDAR*. This will basically check to see if %event is empty or if it matches the previous event, which in either case means there is no new event at this time. Replace MYCALENDAR with the name of the calendar you want to pull from.
  8. Variables --> Variable Convert. Name %schedstart, set Function to "Seconds to Long Date Time." Store Result In %time. Once you've found an event, convert the time it starts at to a human readable time.
  9. Variables --> Variable Split. Name %time, splitter is 2016. We know what today's date is, so let's split the variable to only give us the time today and not the date.
  10. Variables --> Array Push. Name %calevents, Position 999, Value should be
    Code:
    %event1, at %time 2
    Here, we're pushing the event title and its time into an array that we'll read from later.
  11. Variables --> Variable Set. Name %doubleevent, To %event1. Save the event title so when we do our next check we compare to see if it matches, if so, don't save it again!
  12. Task --> End If.
  13. Variables --> Variable Add. Name %schedstart, Value 900. Increment the time to check next by 15 minutes (ie. move up through the day).
  14. Task --> Goto. Type "Action Label" and label should be "TEST NEXT EVENT". Check If and set it to If %schedstart < %schedend. Basically, loop back if we're still in the same day testing the calendar.
  15. Alert --> Say. Text: "You have no events today." Check If and set it to if %calevents(#) eq 0
  16. Alert --> Say. Text: "You have one event today." Check If and set it to if %calevents(#) eq 1.
  17. Alert --> Say. Text: "You have %calevents(#) events today." Check If and set it to if %calevents(#) > 1.
  18. Task --> For. Variable %eventtosay, Items %calevents:)). In this for loop, we're simply reading the calendar events we've found in order.
  19. Alert --> Say. Text: "%eventtosay"
  20. Task --> End For.

Here are screenshots of the task:
JmIPouF.jpg

8OQ3Cfz.jpg

6Qp6j9g.jpg


Now you might ask, what do I do with this task? That's up to you! You can have this task run whenever your alarm is dismissed if you're using an app like AlarmPad, or you can make it run when you dismiss an NFC tag using an app like Trigger.

Below, I am attaching the XML file for the task that you can import. IF YOU IMPORT THIS, YOU MUST EDIT ACTION #6 (THE IF ACTION) AND CHANGE *MYCALENDAR*. REPLACE "MYCALENDAR" WITH THE NAME OF THE CALENDAR YOU WANT TO PULL FROM. You can import a task by putting it in /sdcard/Tasker/tasks. Then when inside Tasker, long-press on the Tasks tab up top and press import.
There is a bug. for calendar events, which doesn't have any duration like if it is scheduled at 12pm only, your task is missing out on those. Those events which have duration like 5mins etc, your task is able to pull the event data
Please guide.
Thanks
 

MishaalRahman

Retired Editor in Chief
Nov 2, 2015
1,043
2,142
www.xda-developers.com
Yeah that's an issue with how often I've set it up to "poll" your calendar for events. If you change the number of seconds you'll be able to get a more accurate result, but it will take longer to run the task. Alternatively, you can use the Google Calendar API to find all the events.
 

vickylahkarbytes

Senior Member
Dec 25, 2013
68
13
Yeah that's an issue with how often I've set it up to "poll" your calendar for events. If you change the number of seconds you'll be able to get a more accurate result, but it will take longer to run the task. Alternatively, you can use the Google Calendar API to find all the events.
Hello,
Thank you for the reply.
I tried using the Tasker plugin CalendarTask to pull the event data. It is successfully pulling all those events whether they are having duration or not
But the problem is setting up all the commands as you had set it up! https://play.google.com/store/apps/...ask&pcampaignid=APPU_1_zGpwV_zGI8yNvQT_vb7YCQ
 

wojtula

Member
Nov 9, 2010
5
0
I have been working on modifying these tasks to meet my requirements, and would like to share the results with everyone.
I had a few issues with the way the original calendar task handled overlapping events. All day events and items that overlapped, sometimes either showed the wrong time, or showed multiple times, or did not show at all. Almost made me wake up late one morning.
For all day events, I I set a variable at the beginning to no, and the first event that was not a all day event I set it to yes. from then on, all day events were ignored.
For overlapping events, right before the if loop that parsed all the events I set up a for loop to pass overlapping events to the for loop one at a time. This created the need to rearrange the doublecheck variable, so I appended each event as it went through the for loop and had to search through the variable separately before the loop.

I also split it into two profiles, one that runs in the evening and will set my alarm for work in the morning, and another that runs in the morning that notify's me verbally and with a popup.

I can write a whole Guide if anyone wants to see what I did so they can incorporate it, but for now I just attached the profiles. Let me know if anyone's interested!

I would like to specify only one calendar ( 'job' calendar) in this profile. Is it possible to set it up?
I mean those profiles:
xml Calendar_Today.prf.xml
xml Calendar_Tomorrow.prf.xml
 

nay.e

New member
Aug 4, 2016
2
0
Hi ! Glad to see your post ! Unfortunately i have a problem with the IF condition, probably with the %event(#) neq 0 case :(((( any ideas ?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 16
    You're a busy person, and you've decided to organize your busy life by placing all your events on Google Calendar. If this describes you, then you might like to know that you can query Calendar for its events and set it up to notify you however you want. This means you don't have to open the app or even display a widget if you want to see what your events for the day are. Here's how.

    This guide is based heavily off of the work of redditor CallMeLucky but written to be more friendly and with more documentation. Credits for the implementation go to him.

    Prerequisites

    • Google Calendar

    Instructions

    1. Create a new task, and name it "Get Events."
    2. Variables --> Variable Convert. Convert %DATE, set the Function to "Date Time to Seconds" and Store Result In %date.
    3. Variables --> Variable Set. Name %schedstart and set To
      Code:
      %date + (60*60*6)
      This sets the start time to 6AM in the morning. If you want to make it earlier, change the 6 to a different number. CHECK DO MATHS!
    4. Variables --> Variable Set. Name %schedend and set To
      Code:
      %date + (60*60*24)
      This sets the end time to midnight. CHECK DO MATHS!
    5. App --> Test App. Type "Calendar Title", Data %schedstart, Store Result In %event. Set the Label to "TEST NEXT EVENT." This is querying Google Calendar using the time to see if there's an event at that time.
    6. App --> Test App. Type "Calendar Calendar", Data %schedstart, Store Result In %calendar. This is querying the calendar to see, if there's an event, which calendar it belongs to.
    7. Task --> If. If %event(#) neq 0 AND %event1 !~ %doubleevent AND %calendar1 ~ *MYCALENDAR*. This will basically check to see if %event is empty or if it matches the previous event, which in either case means there is no new event at this time. Replace MYCALENDAR with the name of the calendar you want to pull from.
    8. Variables --> Variable Convert. Name %schedstart, set Function to "Seconds to Long Date Time." Store Result In %time. Once you've found an event, convert the time it starts at to a human readable time.
    9. Variables --> Variable Split. Name %time, splitter is 2016. We know what today's date is, so let's split the variable to only give us the time today and not the date.
    10. Variables --> Array Push. Name %calevents, Position 999, Value should be
      Code:
      %event1, at %time 2
      Here, we're pushing the event title and its time into an array that we'll read from later.
    11. Variables --> Variable Set. Name %doubleevent, To %event1. Save the event title so when we do our next check we compare to see if it matches, if so, don't save it again!
    12. Task --> End If.
    13. Variables --> Variable Add. Name %schedstart, Value 900. Increment the time to check next by 15 minutes (ie. move up through the day).
    14. Task --> Goto. Type "Action Label" and label should be "TEST NEXT EVENT". Check If and set it to If %schedstart < %schedend. Basically, loop back if we're still in the same day testing the calendar.
    15. Alert --> Say. Text: "You have no events today." Check If and set it to if %calevents(#) eq 0
    16. Alert --> Say. Text: "You have one event today." Check If and set it to if %calevents(#) eq 1.
    17. Alert --> Say. Text: "You have %calevents(#) events today." Check If and set it to if %calevents(#) > 1.
    18. Task --> For. Variable %eventtosay, Items %calevents:)). In this for loop, we're simply reading the calendar events we've found in order.
    19. Alert --> Say. Text: "%eventtosay"
    20. Task --> End For.

    Here are screenshots of the task:
    JmIPouF.jpg

    8OQ3Cfz.jpg

    6Qp6j9g.jpg


    Now you might ask, what do I do with this task? That's up to you! You can have this task run whenever your alarm is dismissed if you're using an app like AlarmPad, or you can make it run when you dismiss an NFC tag using an app like Trigger.

    Below, I am attaching the XML file for the task that you can import. IF YOU IMPORT THIS, YOU MUST EDIT ACTION #6 (THE IF ACTION) AND CHANGE *MYCALENDAR*. REPLACE "MYCALENDAR" WITH THE NAME OF THE CALENDAR YOU WANT TO PULL FROM. You can import a task by putting it in /sdcard/Tasker/tasks. Then when inside Tasker, long-press on the Tasks tab up top and press import.
    8
    I have been working on modifying these tasks to meet my requirements, and would like to share the results with everyone.
    I had a few issues with the way the original calendar task handled overlapping events. All day events and items that overlapped, sometimes either showed the wrong time, or showed multiple times, or did not show at all. Almost made me wake up late one morning.
    For all day events, I I set a variable at the beginning to no, and the first event that was not a all day event I set it to yes. from then on, all day events were ignored.
    For overlapping events, right before the if loop that parsed all the events I set up a for loop to pass overlapping events to the for loop one at a time. This created the need to rearrange the doublecheck variable, so I appended each event as it went through the for loop and had to search through the variable separately before the loop.

    I also split it into two profiles, one that runs in the evening and will set my alarm for work in the morning, and another that runs in the morning that notify's me verbally and with a popup.

    I can write a whole Guide if anyone wants to see what I did so they can incorporate it, but for now I just attached the profiles. Let me know if anyone's interested!
    3
    EDIT: I've redone and separated this a bit. I found a few problems with it (two calendar entries with the same name after each other won't get listed, for example) so I've jiggled around with it.

    It now uses a global array of upcoming events, within a user-defined time period, and stored a bit more information. Given how long it can take to run for some people with lives (unlike me!) who have many calendar entries, I figured it was best to do this and then let the user run it during the night or something on a trigger. Then, it'll be much quicker when the user actually comes to query the list, because the hard work has been done for them. The task ReadEvents is just one possible implementation of how you can access the global list, by all means shove it in a widget, a notification, anywhere you like (an added bonus of doing the hard work elsewhere).

    A countdown type feature (where you can get how long it is until the event starts) is easy to do, as I've stored the start time as seconds - just subtract %TIMES from %event1 before it's formatted, then shove it through the SecondsToDHMS task and it'll give you days, hours, minutes, and seconds until the event starts. I'm toying with building that in and adding it as a parameter, so depending on how you call the ReadEvents task it'll either just give you the time it starts, how long until it starts, or both.

    I've also put in explanations - you might need to scroll the code window across to see them. Any questions/comments/suggestions/errata please feel free to point them out. I don't have multiple calendars, so I'm not sure how it would work with that - I've incorporated what others have said, but from what I see it might be a little bit more involved to get everything. Please report back!

    Also a huge thanks to @MishaalRahman for giving me the framework to begin with - I've no problem manipulating data, but it can be a bugger in Android/Tasker to figure out which trick you need to do to pull it out of the hat!

    Code:
    Task: Get Events
    1.  Array Clear %CalEvents                                                                                      // Clear existing array
    2.  Variable Convert %DATE to Date Time To Seconds                                                              // Get the current time, convert it into seconds since epoch
    3.  Variable Set %intervalorday to 0                                                                            // Choose whether to check forward from the beginning of the current day, or from the present moment
    4.  Variable Set %interval to 24                                                                                // How many hours to look forward
    5.  Variable Set %testinterval to 60*15 DO MATHS                                                                // How granular the search through the calendar is (60 seconds times 15 minutes)
    6.  Variable Set %schedstart to %TIMES                                                                          // We start now.  There's no point looking back in time.
    7.  Variable Set %schedend to %date + (60*60*%interval) IF %intervalorday eq 0                                  // If we want to check from the beginning of the day, set the end time for (beginning of day + chosen interval)
    8.  Variable Set %schedend to %TIMES + (60*60*%interval) IF %intervalorday eq 1                                 // If we want to check from now, set the end time for (now + chosen interval)
    9.  Test App Calendar Title data %schedstart store as %event LABEL TEST NEXT EVENT                              // Get title, calendar, start time, end time, and location from the current position of the counter in the calendar
    10. Test App Calendar Calendar data %schedstart store as %calendar                                              //
    11. Test App Calendar Start (Seconds) data %schedstart store as %eventstart                                     //
    12. Test App Calendar End (Seconds) data %schedstart store as %eventend                                         //
    13. Test App Calendar Location data %schedstart store as %eventlocation                                         //
    14. If %event(#) neq 0 & %eventstart1%eventend1%eventlocation1%event1 !~ %doubleevent                           // If we find something at the current position in the calendar, and it's not the fingerprint of something else we've seen
    15.      Variable Set %eventdurations to %eventend1-%eventstart1                                                // Find the duration of the event (in seconds)
    16.      Perform Task SecondsToDHMS %par1 %eventdurations return %evenduration                                  // Get a human legible format of the duration
    17.      Array Push %CalEvents position 9999 value %eventstart1::%event1::%eventlocation1::%eventduration      // Add the information to the global list of upcoming events                                                                                                      
    18.      Variable Set %doubleevent to %eventstart1%eventend1%eventlocation1%event1                              // Set the signature for the current entry                                                                                                                        
    19. End If                                                                                                      //                                                                                                                                                                
    20. Variable Add %schedstart value %testinterval                                                                // Increment the counter                                                                                                                                          
    21. Goto Action Label TEST NEXT EVENT                                                                           // Check the next position                                                                                                                                        
    
    Task: SecondsToDHMS
    1.  Variable Set %days to floor(%par1 / 86400) DO MATHS 
    2.  Variable Set %hours to floor((%par1 % 86400) / 3600) DO MATHS                                                                                                                                                                                                                 
    3.  Variable Set %minutes to floor((%par1 % 3600) / 60) DO MATHS
    4.  Variable Set %seconds to %par1 % 60
    5.  Variable Set %return to %days day APPEND, IF %days eq 1
    6.  Variable Set %return to %hours hour APPEND, IF %hours eq 1
    7.  Variable Set %return to %minutes minute APPEND, IF %hours eq 1
    8.  Variable Set %return to %seconds second APPEND, IF %seconds eq 1
    9.  Variable Set %return to %days days APPEND, IF %days > 1
    10. Variable Set %return to %hours hours APPEND, IF %hours > 1
    11. Variable Set %return to %minutes minutes APPEND, IF %minutes > 1
    12. Variable Set %return to %seconds seconds APPEND, IF %seconds > 1
    13. Return %return
    
    Task: ReadEvents
    1.  IF %CalEvents(#) > 0                                                                                        // If there any events in the global list    
    2.     For %event in %CalEvents()                                                                               // Iterate through them
    3.         Variable Split %event splitter ::                                                                    // Split the entry up
    4.         Array Push %calevents position 9999 value %event IF %event1 > %TIMES                                 // If the event hasn't passed yet, add it to the local list
    5.     End For                                                                                                  //
    6.     Say You have no events today. IF %calevents(#) eq 0                                                      // If all the events have passed, say there aren't any upcoming
    7.     IF %calevents(#) > 0                                                                                     // If there are events still to come
    8.         Say You have one upcoming event IF %calevents(#) eq 1                                                // Say if there's one
    9.         Say You have %calevents(#) upcoming events IF %calevents(#) > 1                                      // Say if there's more
    10.       For %event in %calevents()                                                                            // Iterate through the local list
    11.           Variable Split %event splitter ::                                                                 // Split the entry
    12.           Variable Convert %event1 Seconds to Medium Date Time store in %time                               // Convert the time from seconds to something humans can understand
    13.           Say %time: %event2: at %event3: for %event4                                                       // Say the event
    14.       End For                                                                                               //
    15.   End If                                                                                                    //
    16. Else                                                                                                        //
    17.    Say You have no upcoming events                                                                          // If there's nothing in the global list, then there can't be any upcoming, so tell the user.
    2
    how about if you have multiple calendars?

    Then simply remove the if condition that requires you to set a specific calendar
    2
    @EnIXmA

    The note at the end of the numbered instructions reads in part, "IF YOU IMPORT THIS, YOU MUST EDIT ACTION #6 (THE IF ACTION) AND CHANGE *MYCALENDAR*. REPLACE "MYCALENDAR" WITH THE NAME OF THE CALENDAR YOU WANT TO PULL FROM."

    I'm sure you recall that when you linked to the various Google services (including calendar), you were asked for the email address of your Gmail account. In this case, you would enter (without the quotes), "*[email protected]*" to replace "*MYCALENDAR*" in step 6.

    As an aside, I set AutoSync off and run a profile that turns it on for a few minutes every hour. When AutosSync is turned on it attempts to sync all enabled accounts. So when I am ready to use this profile for my morning agenda, I turn on AutoSync about 5 minutes prior to running 'GetEvents'.

    I have taken this nifty task and am modifying it to retrieve my 'next' event. If there is a location stored in the event, that information will be passed to Maps for navigation (per the VERY useful tip from the OP located in post 21). I only need to sync Calendar if I have added an event that will occur within the hour. Keeping AutoSync off is just another way to save battery.

    Hope this helps.

    I am using Google calender, in step 6 what should I can be “my calender”to? Google calendar or leave it as it is?
    Should I change something in step 5 too?

    Keeps saying you have no events today