Feature Request: Add Calendar as an Event

77 views
Skip to first unread message

Scott

unread,
Aug 19, 2017, 10:29:18 AM8/19/17
to Tasker
Reason for Calendar as an Event, not just a State...if an All-Day Event is ID, the Profile remains 'Active' and won't ID any new events.

Abdullah Alahdal

unread,
Aug 19, 2017, 1:26:32 PM8/19/17
to Tasker
A work around is to make 2 profiles one with a state (Calendar) and the other with an event (Variable Set).

In the enter of the state profile make a task to change the variable of the event.

Other solution is to use Intent Received, but this will require you to work with the received variables and decide wither to fire your tasks or no.

Rich D

unread,
Aug 19, 2017, 4:56:25 PM8/19/17
to Tasker Google Groups Post


> A work around is to make 2 profiles one with a state (Calendar) and the other with an event (Variable Set).
>
> In the enter of the state profile make a task to change the variable of the event.

This will not work for what the OP is looking for. If there is already a active all day event the calendar profile will not fire again when another calendar event occurs.

>
> Other solution is to use Intent Received, but this will require you to work with the received variables and decide wither to fire your tasks or no.
>

That sounds interesting. Do you have the intent data required for tasker to receive a calendar event?

Abdullah Alahdal

unread,
Aug 20, 2017, 3:11:09 AM8/20/17
to Tasker

That sounds interesting. Do you have the intent data required for tasker to receive a calendar event?


I used this intent >> android.intent.action.PROVIDER_CHANGED

under scheme field, I put content.

I am using this profile to fire a task for any change in the calendar, includes (not limited to) receiving new appointment, canceling, deleting, accepting, sending, etc.

This was one of my awesome achievement along with Lightning Launcher, I have made a monitor for the meeting rooms to allow our office boy make the arrangements on time, see attached photo.


IMG_20170415_150050.jpg

Rich D

unread,
Aug 20, 2017, 8:22:56 AM8/20/17
to Tasker Google Groups Post


That sounds interesting. Do you have the intent data required for tasker to receive a calendar event?


I used this intent >> android.intent.action.PROVIDER_CHANGED

under scheme field, I put content.


Cool, that works. Which recieved variables do you use, and what kind of data is available?  The only variables I found just give information on the actual intent IE - %intent data which does not seem usefull.  Are there extras you can access? 

Abdullah Alahdal

unread,
Aug 20, 2017, 8:51:36 AM8/20/17
to Tasker

Cool, that works. Which recieved variables do you use, and what kind of data is available?  The only variables I found just give information on the actual intent IE - %intent data which does not seem usefull.  Are there extras you can access? 

In fact, I have not checked the variables coming from this event, I run an SQL query (Formatted URI) from calendar events table every time to check all required information later than %TIMES


to get events details: content://com.android.calendar/events
to get the attendees details: content://com.android.calendar/attendees

Rich D

unread,
Aug 20, 2017, 9:07:38 AM8/20/17
to Tasker Google Groups Post


In fact, I have not checked the variables coming from this event,

From what I have found there is no such data included with this intent. So querying the calendar is the only option. This can be done with the Tasker 'Test app' action.




I run an SQL query (Formatted URI) from calendar events table every time to check all required information later than %TIMES

Could you post the exported Tasker description of how you do this. I am not familiar with SQL at all.



Abdullah Alahdal

unread,
Aug 20, 2017, 9:50:37 AM8/20/17
to Tasker
Could you post the exported Tasker description of how you do this. I am not familiar with SQL at all.


Test Calendar (605)
A1: SQL Query [ Mode:URI Formatted File:content://com.android.calendar/events Table: Columns:_id, title, description, eventLocation, organizer, dtstart, dtend Query:calendar_id = 4 Selection Parameters: Order By: Output Column Divider: Variable Array:%events Use Root:Off ] 
A2: Flash [ Text:%events() Long:Off ]

You need to know the calendar_id which contains the events you want to retrieve from (it is 4 in my case). there are other columns, but i feel above are enough to retrieve.

Rich D

unread,
Aug 20, 2017, 11:09:20 AM8/20/17
to Tasker Google Groups Post



Test Calendar (605)
A1: SQL Query [ Mode:URI Formatted File:content://com.android.calendar/events Table: Columns:_id, title, description, eventLocation, organizer, dtstart, dtend Query:calendar_id = 4 Selection Parameters: Order By: Output Column Divider: Variable Array:%events Use Root:Off ] 
A2: Flash [ Text:%events() Long:Off ]


Thanks for that. I did get it working but for most applications of this It would appear easier to just use the Tasker 'Test app' action. 

 The received intent is very useful and allows for a much simpler approach then What I had come up with before. 

@ OP . This should be enough info to get you going, Post back if you get stuck.. 

John Doe

unread,
Aug 20, 2017, 11:40:56 AM8/20/17
to Tasker
I want just to add that this intent is not "public" and it could not work with different calendar apps. Android has a built-in mechanism to broadcast this kind of information but it's not possible to use it via intents. It requires a specific service.

Scott

unread,
Aug 20, 2017, 2:30:39 PM8/20/17
to Tasker
I'm a bit confused...

1) Below is what I have for the Test Calendar Task, however, there's no Query section, and where do I add the calendar ID?
2) How to discover the calendar ID?
3) How do I write a Profile to watch for changes to a variable?
4) What variable am I watching for?
5) How do I implement the intent, android.intent.action.PROVIDER_CHANGED?

Test Calendar (422)
A1: SQL Query [ Mode:URI Formatted File:content://com.android.calendar/events Table: Columns:calendar_id, title, description, eventLocation, organizer, dtstart, dtend Query: Selection Parameters: Order By: Output Column Divider: Variable Array:%events Use Root:Off ] 

Rich D

unread,
Aug 20, 2017, 3:37:16 PM8/20/17
to Tasker Google Groups Post

I'm a bit confused...


As I stated above I personally would not use the sql action. This seems to give all of calendar data that you would have to parse though. It would be far easier to use the Tasker action app / test app / test calendar every time the profile fires.

 But to answer your question..


This took me a few minutes to figure out as well.. Here is a screen shot of the set up that works for me for the sql action


2) How to discover the calendar ID?

Not sure on that one I tried 4 then 3 then 1 then 1 and one seemed to give the 



3) How do I write a Profile to watch for changes to a variable?

Disregard that approach, it will not work


4) What variable am I watching for?

Disregard that approach, it will not work


5) How do I implement the intent, android.intent.action.PROVIDER_CHANGED?


I included a screen shot of the intent received context  as well. 

I will be building a simple project for this and will post what I come up with..





Screenshot_20170820-152408.png
Screenshot_20170820-153305.png

Rich D

unread,
Aug 20, 2017, 3:45:36 PM8/20/17
to Tasker Google Groups Post


I want just to add that this intent is not "public" and it could not work with different calendar apps. Android has a built-in mechanism to broadcast this kind of information but it's not possible to use it via intents. It requires a specific service.


Thanks for the heads up.  Am I correct in assuming it should work across multiple devices if you just use the Google calendar?

Does this specific service cost $  ?

Is there a way to do this with native Tasker actions/ contexts?

Will Any of your plug-ins help with this issue or is it possible to build such a plug in. This issue has come up in past with no clear easy solution. 

Thanks,   Rich..



John Doe

unread,
Aug 20, 2017, 4:03:18 PM8/20/17
to Tasker
> Thanks for the heads up. Am I correct in assuming it should work across multiple devices if you just use the Google
> calendar?

It could. However since it's not documented it can be removed at any time, in addition it isn't in the broadcast whitelist so it won't be possible to listen to it in Oreo using an implicit receiver, but I don't think Tasker will have problems with it.

> Does this specific service cost $ ?

Cost?? I don't understand. I meant an Android service.

> Is there a way to do this with native Tasker actions/ contexts?

I don't think so, but maybe Pent knows something more :)

> Will Any of your plug-ins help with this issue or is it possible to build such a plug in. This issue has come up in > past with no clear easy solution.

It depends on the goal. CalendarTask has an event to detect calendar changes without using that intent, so it works for any device. The event requires Nougat and you don't need to pay anything to use it, I don't know if you meant something like that with "cost". In the task you need to query the calendar with a get event action and no, you don't need to play with calendar id and SQL :)

Rich D

unread,
Aug 20, 2017, 4:26:15 PM8/20/17
to Tasker Google Groups Post
It could. However since it's not documented it can be removed at any time, in addition it isn't in the broadcast whitelist so it won't be possible to listen to it in Oreo using an implicit receiver, but I don't think Tasker will have problems with it.

Ok, thanks..

> Does this specific service cost $  ?

Cost?? I don't understand. I meant an Android service.

Sorry, disregard that question. I had my terminology mixed up..



> Will Any of your plug-ins help with this issue or is it possible to build such a plug in. This issue has come up in   > past with no clear easy solution.

It depends on the goal.

The goal is that since Tasker only offers a calandar "state" context then if I already have a all day event for today I can not detect any further calendar events until that all day event is no longer true. 




CalendarTask has an event to detect calendar changes without using that intent, so it works for any device.

If the event will fire while there is a existing all day calendar event then yes this will work.

Am I correct in assuming your plug in uses the service you mentioned above?

John Doe

unread,
Aug 20, 2017, 4:55:33 PM8/20/17
to Tasker
yes, the plug-in uses the new android architecture. It's the reason why you need Nougat. I think we are mixing the things up. The event (and the intent) are used to detect when a new event is added, when deleted or when modified. I'm not sure OP is asking for that event. The best thing you can do is to setup an array with events start times and then use a time profile with start time equals to end time. In the task you can pop the array of times. The array can be filled at boot or in the morning. Another alternative would be to setup a silence reminder in the calendar, then catch the notification event.

Rich D

unread,
Aug 20, 2017, 5:44:47 PM8/20/17
to Tasker Google Groups Post

I think we are mixing the things up. The event (and the intent) are used to detect when a new event is added, when deleted or when modified.


Damm, I did misunderstand the intent and never properly tested it. I just made a new all day event for today and assumed it was firing the context because of the actual event not because I just created it. 


I'm not sure OP is asking for that event.

You are correct..




The best thing you can do is to setup an array with events start times and then use a time profile with start time equals to end time. In the task you can pop the array of times. The array can be filled at boot or in the morning. Another alternative would be to setup a silence reminder in the calendar, then catch the notification event.


Good ideas, However a long while ago I did make a work around for this that does work. It is just a bit complex an I was hoping easier solution.  The original post can be found here.


However here is the description of it. 


This approach requires 3  profiles.

1-"Calendar Main"  triggers on every calendar event then adds that event name to its 'ignore' list so even if it is a all day event it will fire on the next calendar event. If the event is 'not' a all day event it will set a global variable to trigger the 'Calendar Timed Event' profile that will trigger on any timed event.

2- "Calendar Timed Events"  will trigger on any Timed (Not all day) events

3- "Calendar All Off"  is needed to reset %All_day_array when "All" Calendar events Stop. 


Profile: Calender Main (777)
State: Calendar Entry [ Title:%All_day_arr Location:* Description:* Available:Any Calendar:Google:ricpdjrr@gmail.com ]
Enter: Anon (778)
<on>
A1: Anchor 
A2: Test App [ Type:Calendar All Day Data:%TIMES Store Result In:%cal_allday Continue Task After Error:On ] 
A3: Test App [ Type:Calendar Title Data:%TIMES Store Result In:%cal_title Continue Task After Error:On ] 
A4: [X] Flash [ Text:%cal_allday(:) Long:Off ] 
A5: For [ Variable:%index Items:1:%cal_title(#) ] 
A6: If [ %All_day_arr !~ *%cal_title(%index)* ]
A7: Variable Set [ Name:%All_day_arr To:! Do Maths:Off Append:Off ] If [ %All_day_arr ~R \* ]
A8: Variable Set [ Name:%All_day_arr To:/%cal_title(%index) Do Maths:Off Append:On ] 
A9: Variable Set [ Name:%Timed_cal To:/%cal_title(%index) Do Maths:Off Append:On ] If [ %cal_allday(%index) ~ no ]
A10: End If 
A11: End For 
A12: [X] Flash [ Text:%All_day_arr Long:Off ]

Profile: Calendar All Off (779)
State: Calendar Entry [ Title:* Location:* Description:* Available:Any Calendar:Google:ricpdjrr@gmail.com ]
Enter: Anon (780)
A1: Notify [ Title:Active Events All On %TIME Text: Icon:null Number:0 Permanent:Off Priority:3 ]

Exit: Anon (784)
A1: Notify [ Title:No Active Events All Off %TIME Text: Icon:null Number:0 Permanent:Off Priority:3 ] 
A2: Variable Set [ Name:%All_day_arr To:* Do Maths:Off Append:Off ]

Profile: Calendar Timed Events (776)
State: Calendar Entry [ Title:%Timed_cal Location:* Description:* Available:Any Calendar:Google:ricpdjrr@gmail.com ]
Enter: Anon (785)
A1: Notify [ Title:Timed Calendar Event Ran %TIME Text: Icon:null Number:0 Permanent:Off Priority:3 ]

Exit: Anon (786)
A1: Notify [ Title:Timed Events Stopped %TIME Text: Icon:null Number:0 Permanent:Off Priority:3 ] 
A2: Variable Clear [ Name:%Timed_cal Pattern Matching:Off ] 
A3: Variable Set [ Name:%All_day_arr To:* Do Maths:Off Append:Off ]


Abdullah Alahdal

unread,
Aug 20, 2017, 5:57:28 PM8/20/17
to Tasker
I have mentioned earlier this intent will fire with any changes in the calendar :-s.

I was trying to help but it seems I got I the same trap of mis-explanation.

Scott

unread,
Aug 20, 2017, 11:49:44 PM8/20/17
to tas...@googlegroups.com
Abdullah- Thanks for your contributions... I'm not certain how the intent will work to ID new non all-day day events. Could you provide entire Profile/Task descriptions for us to work with.

Scott

Abdullah Alahdal

unread,
Aug 21, 2017, 12:48:17 AM8/21/17
to Tasker
Abdullah- Thanks for your contributions... I'm not certain how the intent will work to ID new non all-day day events. Could you provide entire Profile/Task descriptions for us to work with.

Scott,

The intent is just to trigger the Event for every change to the calendar provider (database). the whole idea comes in how you deal with the Task and how you manipulate the data after your SQL query.

For example, following is my profile to capture all events during the day in order to display them on the board using Lightening Launcher (photo shared earlier). Go through it and if you need further explanation on specific action, let me know.

Profile: Calendar Updates (4)
Event: Intent Received [ Action:android.intent.action.PROVIDER_CHANGED Cat:None Cat:None Scheme:content Mime Type:* ]
Enter: Today Events (3)
A1: Lightning Script [ Configuration:Clear Events Timeout (Seconds):0 ] 
A2: Lightning Script [ Configuration:Label Date%DATE Timeout (Seconds):0 ] 
A3: Variable Set [ Name:%daystart To:%DATE 0.0 Recurse Variables:Off Do Maths:Off Append:Off ] 
A4: Variable Set [ Name:%dayend To:%DATE 23.59 Recurse Variables:Off Do Maths:Off Append:Off ] 
A5: Variable Convert [ Name:%daystart Function:Date Time to Seconds Store Result In: ] 
A6: Variable Convert [ Name:%dayend Function:Date Time to Seconds Store Result In: ] 
A7: Variable Set [ Name:%daystart To:%daystart*1000 Recurse Variables:Off Do Maths:On Append:Off ] 
A8: Variable Set [ Name:%dayend To:%dayend*1000 Recurse Variables:Off Do Maths:On Append:Off ] 
A9: SQL Query [ Mode:URI Formatted File:content://com.android.calendar/events Table: Columns:_id, title, eventLocation, organizer, dtstart, dtend Query:calendar_id = 3 and eventLocation <> "" and dtstart between %daystart and %dayend and title not like "%Canceled:%" Selection Parameters: Order By:dtstart Output Column Divider:| Variable Array:%events Use Root:Off ] 
A10: For [ Variable:%eventdetails Items:%events() ] 
A11: Variable Set [ Name:%itemno To:%itemno+1 Recurse Variables:Off Do Maths:On Append:Off ] 
A12: Variable Split [ Name:%eventdetails Splitter:| Delete Base:Off ] 
A13: SQL Query [ Mode:URI Formatted File:content://com.android.calendar/attendees Table: Columns:attendeeName Query:event_id = %eventdetails(1) Selection Parameters: Order By: Output Column Divider:| Variable Array:%attendees Use Root:Off ] 
A14: Variable Set [ Name:%attendeesno To:%attendees(#)-1 Recurse Variables:Off Do Maths:On Append:Off ] 
A15: If [ %attendees() ~ *Priority Member*/*Priority Member*/*Priority Member* ]
A16: Variable Set [ Name:%attpriority To:1 Recurse Variables:Off Do Maths:Off Append:Off ] 
A17: Else 
A18: Variable Set [ Name:%attpriority To:0 Recurse Variables:Off Do Maths:Off Append:Off ] 
A19: End If 
A20: Lightning Script [ Configuration:Today Events%eventdetails|%daystart|%attpr… Timeout (Seconds):0 ] 
A21: Array Clear [ Variable Array:%attendees ] 
A22: End For 
A23: SQL Query [ Mode:URI Formatted File:content://com.android.calendar/events Table: Columns:_id, title, eventLocation, organizer, dtstart, dtend Query:calendar_id = 3 and dtend > %TIMEMS and eventLocation <> "" and dtstart between %daystart and %dayend and title not like "%Canceled:%" Selection Parameters: Order By:dtstart Output Column Divider:| Variable Array:%timeout Use Root:Off ] 
A24: If [ %timeout(#) > 0 ]
A25: Wake screen [ Configuration:Wake Timeout (Seconds):5 ] 
A26: Display Timeout [ Secs:0 Mins:0 Hours:8 ] 
A27: Else 
A28: Display Timeout [ Secs:30 Mins:0 Hours:0 ] 
A29: System Lock 
A30: End If 
A31: Flash [ Text:%events(#) Event(s) on %DATE Long:Off ] 
A32: Variable Set [ Name:%DayAdj To:0 Recurse Variables:Off Do Maths:Off Append:Off ] 
A33: Flash [ Text:%events() Long:Off ]
Reply all
Reply to author
Forward
0 new messages