FORUMS
Remove All Ads from XDA

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

853 posts
Thanks Meter: 1,891
 
By MishaalRahman, Editor in Chief on 10th March 2016, 05:07 AM
Post Reply Email Thread
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:




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.
Attached Files
File Type: xml Get_Events.tsk.xml - [Click for QR Code] (5.5 KB, 9050 views)
The Following 16 Users Say Thank You to MishaalRahman For This Useful Post: [ View ]
10th March 2016, 08:02 PM |#2  
AKW's Avatar
Senior Member
Flag Jacksonville
Thanks Meter: 571
 
More
I love this task. I've been using it for a hot minute. I have it run immediately after another task that uses an HTTP get to pull and read the weather for the day as well. Great combo to use with an "Alarm Dismissed" trigger like you suggested.
The Following User Says Thank You to AKW For This Useful Post: [ View ] Gift AKW Ad-Free
10th March 2016, 09:32 PM |#3  
sbcrumb's Avatar
Senior Member
Flag Ohio
Thanks Meter: 358
 
Donate to Me
More
how about if you have multiple calendars?
The Following User Says Thank You to sbcrumb For This Useful Post: [ View ] Gift sbcrumb Ad-Free
11th March 2016, 02:36 AM |#4  
MishaalRahman's Avatar
OP Editor in Chief
Thanks Meter: 1,891
 
More
Quote:
Originally Posted by jskala

how about if you have multiple calendars?

Then simply remove the if condition that requires you to set a specific calendar
The Following 2 Users Say Thank You to MishaalRahman For This Useful Post: [ View ]
11th March 2016, 02:52 AM |#5  
Senior Member
Flag Portland
Thanks Meter: 23
 
More
Quote:
Originally Posted by jskala

how about if you have multiple calendars?

I second the motion.

I have one exclusively for my work schedule, and one for my personal schedule. It would be ideal to be able to add several calendars at once.

For example, today I had work and a service repair call for my place. Yesterday, I had work, my child had an appointment and a Parent Teacher Meeting all in different calendars. To know that there are three events or all on one schedule that lists the agenda would be cool.
11th March 2016, 02:56 AM |#6  
Member
Thanks Meter: 6
 
More
in topic "5", when you say "app" what exactly I have to do? I didn't get it. Sorry I'm a newbie

---------- Post added at 02:56 AM ---------- Previous post was at 02:52 AM ----------

Quote:
Originally Posted by Erlonbie123

in topic "5", when you say "app" what exactly I have to do? I didn't get it. Sorry I'm a newbie

omg, nevermind, sorry! lol
kitkat85
11th March 2016, 12:34 PM |#7  
Guest
Thanks Meter: 0
 
More
You can use just a couple of actions of CalendarTask plugin in order to that.
11th March 2016, 03:18 PM |#8  
Senior Member
Milano
Thanks Meter: 39
 
More
i love your idea, it's amazing thanks!!

i'm trying to work in a mod: i don't like the voiceover option, i prefer to receive a notification with the list of events. then if i click on the notification it should open the calendar to check the details.

my mod:

- removed 15. alert, 15. alert, 17. alert
- replaced 19. alert with "Notify sound": Title "Daily Agenda"; Text: "%eventtosay"; Action: "open google calendar"; if "%calevents(#) >0

doing like that i receive a notification with sound (i've added the calendar icon too) instead the voice over.

I have 2 problems, i hope you can help me:
1. all the events are showed once at the time in the same notification (e.g. if i have 3 events, i receive a notification with event 1, than change to event 2 and event 3 in few seconds); it would be nice to have a a list with all the events
2. when i click on the action to open the calendar, it opens the calendar in background without closing the notification panel (see the screenshot)

any suggestions??

thanks a lot!!
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2016-03-11-16-16-06.png
Views:	1642
Size:	108.9 KB
ID:	3679324  
12th March 2016, 07:15 PM |#9  
Junior Member
Flag Raleigh
Thanks Meter: 1
 
More
Great work
Hi, I like the calendar program. I have a question. Where do you get the Calendar Task plugin for reading different events? For example
Personal Calendar: Sister Birthday
Appointments: Dr. Appointment.

Etc.
Another feature that would be good is to read the events out for the week or have a drop down box with selecting By Week or By Day.
13th March 2016, 12:35 PM |#10  
Member
Thanks Meter: 5
 
More
I'm trying to make tasker read my events of tomorrow. I changed %date + (60*60*25) and %date + (60*60*48)
Now I want it to say the day and date of tomorrow (for instance "14.03.2016. Tomorrow is Monday.").
I can't use the default variables like %DATE and %DAYW, because they are for the current day.

I already tried converting the schedstart value from seconds back to date.
kitkat85
13th March 2016, 02:06 PM |#11  
Guest
Thanks Meter: 0
 
More
Quote:
Originally Posted by flash629

Hi, I like the calendar program. I have a question. Where do you get the Calendar Task plugin for reading different events? For example
Personal Calendar: Sister Birthday
Appointments: Dr. Appointment.

Etc.
Another feature that would be good is to read the events out for the week or have a drop down box with selecting By Week or By Day.

You find it on the play store obviously
Post Reply Subscribe to Thread

Tags
assistant, calendar, events, google calendar, tasker

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes