Calendar Test Help

1,359 views
Skip to first unread message

Matt

unread,
Aug 14, 2014, 7:17:53 AM8/14/14
to tas...@googlegroups.com
Hi,

I am trying to create a task that will at midnight check my calendar at 8am and every 10 minutes there after up until 5pm (the times don't have to be exact) and store all of the events for that day in a variable (which I want to use on a scene to be triggered later in the day) The task I have at the moment is:

Read Calendar (401)
A1: Variable Set [ Name:%step To:0 Do Maths:Off Append:Off ] 
A2: Variable Set [ Name:%eight To:%TIMES+28800 Do Maths:On Append:Off ]  (I have removed the +28800 for testing but it still doesn't work)
<StartLoop>
A3: Anchor 
A4: Variable Set [ Name:%eight To:%eight+%step Do Maths:Off Append:Off ] 
A5: Test App [ Type:Calendar Title Data:%eight Store Result In:%Events ]      (I have tried all of the Calendar tests and none return anything)
A6: Array Push [ Name:%arrEvents Position:1 Value:%Events Fill Spaces:Off ] If [ %Events Set ] (from the Userguide I think this is redundant as the result is an array anyway)
A7: Variable Set [ Name:%step To:%step+600 Do Maths:On Append:Off ] 
A8: If [ %step < 61200 ]
A9: Goto [ Type:Action Label Number:1 Label:StartLoop ] 
A10: End If 

Read Calendar (401)
A1: Variable Set [ Name:%step To:0 Do Maths:Off Append:Off ] 
A2: Variable Set [ Name:%eight To:%TIMES+28800 Do Maths:On Append:Off ]  (I have removed the +28800 for testing but it still doesn't work)
<StartLoop>
A3: Anchor 
A4: Variable Set [ Name:%eight To:%eight+%step Do Maths:Off Append:Off ] 
A5: Test App [ Type:Calendar Description Data:%eight Store Result In:%Events ] (I have tried all of the Calendar tests and none return anything)
A6: Variable Set [ Name:%step To:%step+600 Do Maths:On Append:Off ] 
A7: If [ %step < 61200 ]
A8: Goto [ Type:Action Label Number:1 Label:StartLoop ] 
A9: End If 

However neither %Events nor %arrEvents seem to get populated (I have created a test appointment).

I know I am probably doing something daft but I can't figure out what!?

Thanks

Matt

easiuser

unread,
Aug 14, 2014, 9:10:48 AM8/14/14
to tas...@googlegroups.com
The results go into an array because their may be more than one result (ie multiple calendar events).  Check the value of %Events() or %Events1, %Events2, etc.

Brandon Horwath

unread,
Aug 14, 2014, 4:44:52 PM8/14/14
to tas...@googlegroups.com
A4: Variable Set [ Name:%eight To:%eight+%step Do Maths:Off Append:Off ]

I still think this ^ is your issue instead.

Bob Hansen

unread,
Aug 14, 2014, 5:25:59 PM8/14/14
to tas...@googlegroups.com
Brandon is right.

A4: Variable Set [ Name:%eight To:%eight+%step Do Maths:Off Append:Off ]

Do maths must be: On

Matt

unread,
Aug 15, 2014, 5:31:37 AM8/15/14
to tas...@googlegroups.com
I think you were both correct to be honest, I needed the Do Maths and %step was growing exponentially... I've changed it to the following which still doesn't work!:

I take it that I am right in thinking that if I have an hour long appointment at 12 mid day called Google Test and run this task (when it's working!!) at 10:22 it should hit the appointment at 12:02 and send that to the array, it doesn't matter that it finds the appointment after it is set to start? When I flash Events1 below I just get %Events1 so it's not being set...

Thanks very much for your help.

Read Calendar (401)
A1: Variable Set [ Name:%step To:0 Do Maths:Off Append:Off ] 
A2: Variable Set [ Name:%time To:%TIMES Do Maths:Off Append:Off ] 
<StartLoop>
A3: Anchor 
A4: Test App [ Type:Calendar Title Data:%time Store Result In:%Events ] 
A5: [X] Flash [ Text:%time Long:On ] 
A6: [X] Flash [ Text:%step Long:Off ] 

A7: Variable Set [ Name:%step To:%step+600 Do Maths:On Append:Off ] 
A8: If [ %step < 61200 ]
A9: Variable Set [ Name:%time To:%time+%step Do Maths:On Append:Off ] 
A10: Goto [ Type:Action Label Number:1 Label:StartLoop ] 
A11: End If 
A12: [X] Flash [ Text:%step Long:Off ] 
A13: [X] Flash [ Text:%time Long:On ] 
A14: Flash [ Text:%Events1 Long:Off ] 

Brandon Horwath

unread,
Aug 15, 2014, 3:27:06 PM8/15/14
to tas...@googlegroups.com
You're probably running into issues based on when you're testing, and the derived calculations to obtain testing times based on %TIMES, etc.

Ideally, you'll want a setup that handles a variable degree of flexibility to begin scan intervals, adjusted so the checks always start for 8am that day, and 5pm that night.

This will do that:

All Events 8am To 5pm (417)
A1: Flash [ Text:Started Long:Off ]
A2: Variable Set [ Name:%time To:%TIME Do Maths:On Append:Off ]
A3: Variable Split [ Name:%time Splitter:. Delete Base:On ]
A4: Variable Set [ Name:%time1 To:(23-%time1)*60 Do Maths:On Append:Off ]
A5: Variable Set [ Name:%time2 To:60-%time2 Do Maths:On Append:Off ]
A6: Variable Add [ Name:%time1 Value:%time2 Wrap Around:0 ]
A7: Variable Set [ Name:%after_minutes To:%time1 Do Maths:On Append:Off ]
A8: Variable Set [ Name:%before_minutes To:%time1 - 1441 Do Maths:On Append:Off ]
A9: Variable Set [ Name:%minutes_end To:540 Do Maths:Off Append:Off ]
A10: Variable Add [ Name:%minutes Value:%before_minutes Wrap Around:0 ]
A11: Variable Set [ Name:%calendar_check To:%minutes * 60 Do Maths:On Append:Off ]
A12: Variable Add [ Name:%calendar_check Value:%TIMES + 28860 Wrap Around:0 ]
A13: Variable Convert [ Name:%calendar_check Function:Seconds to Long Date Time Store Result In:%calendar_begin ]
A14: Variable Set [ Name:%subtract To:10 Do Maths:Off Append:Off ]
A15: Flash [ Text:Analyzing Long:Off ]
A16: Say [ Text:Analyzing Engine:Voice:default:default Stream:5 Pitch:5 Speed:5 Respect Audio Focus:On Network:Off Continue Task Immediately:Off ] If [ %SILENT ~ off ]
<Test Anchor>
A17: Anchor
A18: Test App [ Type:Calendar Title Data:%calendar_check Store Result In:%calendar_results ]
A19: Variable Set [ Name:%results To:,%calendar_results() Do Maths:Off Append:On ] If [ %calendar_results(#) != 0 ]
A20: Variable Set [ Name:%subtract To:%minutes_end Do Maths:Off Append:Off ] If [ %minutes_end < 10 ]
A21: Variable Subtract [ Name:%minutes_end Value:%subtract ]
A22: Variable Add [ Name:%calendar_check Value:%subtract * 60 Wrap Around:0 ]
A23: Goto [ Type:Action Label Number:1 Label:Test Anchor ] If [ %minutes_end != 0 ]
A24: Flash [ Text:Analysis Complete Long:Off ]
A25: Say [ Text:Analysis complete Engine:Voice:default:default Stream:5 Pitch:5 Speed:5 Respect Audio Focus:On Network:Off Continue Task Immediately:Off ] If [ %SILENT ~ off ]
A26: Variable Convert [ Name:%calendar_check Function:Seconds to Long Date Time Store Result In:%calendar_end ]
A27: If [ %results Set ]
A28: Variable Split [ Name:%results Splitter:, Delete Base:Off ]
A29: Array Process [ Variable:%results Type:Remove Duplicates ]
A30: Array Process [ Variable:%results Type:Squash ]
A31: Array Pop [ Variable:%results Position:1 To Var: ]
A32: If [ %results(#) = 0 ]
A33: Say [ Text:No events from %calendar_begin until %calendar_end Engine:Voice:default:default Stream:5 Pitch:5 Speed:5 Respect Audio Focus:On Network:Off Continue Task Immediately:Off ] If [ %SILENT ~ off ]
A34: Else
A35: Say [ Text:According to the calendar for %calendar_begin until %calendar_end, you have %results(#) events, %results() Engine:Voice:default:default Stream:5 Pitch:5 Speed:5 Respect Audio Focus:On Network:Off Continue Task Immediately:On ] If [ %SILENT ~ off ]
A36: End If
A37: Else
A38: Say [ Text:No events from %calendar_begin until %calendar_end Engine:Voice:default:default Stream:5 Pitch:5 Speed:5 Respect Audio Focus:On Network:Off Continue Task Immediately:Off ] If [ %SILENT ~ off ]
A39: End If


And here is the task uploaded for importation:

https://www.dropbox.com/s/b642z65xx59r6xf/All_Events_8am_To_5pm.tsk.xml

Hope this helps.

Matt Vernon

unread,
Aug 15, 2014, 4:39:14 PM8/15/14
to tas...@googlegroups.com

Thanks Brandon, I had seen your other post and I agree more accuracy would be better *but* I've created the following and if I run it at a time when there is a calendar entry with the goto disabled it works, as soon as I enable the goto it stops working (%NewEvent is never populated). I would think now (%TIMES) +600 should be a valid time?

I'll probably have to give up and just use yours but it had become a bit of a challenge!

Test 2 (260)
A1: Variable Set [ Name:%time To:%TIMES+600 Do Maths:On Append:Off ]
A2: Variable Set [ Name:%stop To:%TIMES+86500 Do Maths:On Append:Off ]
A3: Test App [ Type:Calendar Title Data:%time Store Result In:%NewEvent ]
A4: Flash [ Text:%time Long:Off ]
A5: Variable Set [ Name:%time To:%time+600 Do Maths:On Append:Off ]
A6: Goto [ Type:Action Number Number:3 Label: ] If [ %time < %stop]

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/kossTXlwDzc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Brandon Horwath

unread,
Aug 15, 2014, 4:58:57 PM8/15/14
to tas...@googlegroups.com
You're very close...

Test 2 (260)
A1: Variable Set [ Name:%time To:%TIMES+600 Do Maths:On Append:Off ]
A2: Variable Set [ Name:%stop To:%TIMES+86500 Do Maths:On Append:Off ]

A3: Test App [ Type:Calendar Title Data:%time Store Result In:%newevent ]

A4: Flash [ Text:%time Long:Off ]

If %newevent(#) ! eq 0 (maths doesn't equal zero)

For, var: %push items: 1:%newevent(#)

Add action: variable > array push
variable: %NewEvent
position: 999999
value: %newevent(%push)
If %NewEvent() ! R %newevent(%push) (doesn't match regex)

End For

End If

A5: Variable Add [ Name:%time Value:600 Wrap Around:0 ]

A6: Goto [ Type:Action Number Number:3 Label: ] If [ %time < %stop]

Up to you what you want to use. The problem you were having with what you were using recently is your saved results were displayed in %NewEvent() and were being replaced with each check in the loop. So, if the final check in the loop didn't have an event then no events were placed in results. With this method, results are placed in a global array only if the results don't match anything previous stored in the array.

Hope this helps too ;-)

Matt Vernon

unread,
Aug 15, 2014, 5:11:56 PM8/15/14
to tas...@googlegroups.com

Ah! Brilliant that makes sense :-)

Thanks for your help :-)

MattV

Darijo Gospić

unread,
Aug 27, 2015, 7:59:05 PM8/27/15
to Tasker
Is it possible to modify this task to have %event_title and %event_start_time stored in these variables (without the time range - all events of today and tomorrow)?
I'd like to have these 2 info to build a scene e.g. 
Tomorrow events:
1. my sons birthday part, starting at 08:00 h

Matt

unread,
Aug 28, 2015, 8:38:57 AM8/28/15
to Tasker
That's basically what the task does, you might just need to increase the Times in actions 3 & 4

Action 3 sets the Start time to 8 hours from now (the task runs at midnight every day)
Action 4 sets the end time to nearly 17 hours (I only look for appointments during the working day.

My Scene is a bit of a cludge though - I have 4 elements preset to be set to the first 4 entries in the array. This works for me as I never have more than 4 things per day but if you do you might need to change it a bit.

Have a look for topics by Brandon Horwath, he's got some very good celendar related profiles.

MattV


Read Calendars (260)
A1: Array Clear [ Name:%NewEvent ]
A2: Array Clear [ Name:%AppTime ]
A3: Variable Set [ Name:%time To:%TIMES+28800 Do Maths:On Append:Off ]
A4: Variable Set [ Name:%stop To:%TIMES+61140 Do Maths:On Append:Off ]
A5: Variable Set [ Name:%time To:%time+600 Do Maths:On Append:Off ]
A6: Test App [ Type:Calendar Title Data:%time Store Result In:%newevent ]
A7: Test App [ Type:Calendar Start (Seconds) Data:%time Store Result In:%apptime ]
A8: If [ %newevent(#) != 0 ]
A9: For [ Variable:%push Items:1:%newevent(#) ]
A10: Array Push [ Name:%NewEvent Position:999999 Value:%newevent(%push) Fill Spaces:Off ] If [ %NewEvent() !~R %newevent(%push) ]
A11: End For
A12: End If
A13: If [ %apptime(#) != 0 ]
A14: For [ Variable:%push Items:1:%apptime(#) ]
A15: Array Push [ Name:%AppTime Position:999999 Value:%apptime(%push) Fill Spaces:Off ] If [ %AppTime() !~R %apptime(%push) ]
A16: End For
A17: End If
A18: Goto [ Type:Action Number Number:5 Label: ] If [ %time < %stop ]
A19: If [ %AppTime(1) Set ]
A20: Variable Convert [ Name:%AppTime(1) Function:Seconds to Date Time Store Result In: ]
A21: Variable Split [ Name:%AppTime(1) Splitter: Delete Base:Off ]
A22: Variable Set [ Name:%AppStart1 To:%AppTime12 Do Maths:Off Append:Off ]
A23: End If
A24: If [ %AppTime(2) Set ]
A25: Variable Convert [ Name:%AppTime(2) Function:Seconds to Date Time Store Result In: ]
A26: Variable Split [ Name:%AppTime(2) Splitter: Delete Base:Off ]
A27: Variable Set [ Name:%AppStart2 To:%AppTime22 Do Maths:Off Append:Off ]
A28: End If
A29: If [ %AppTime(3) Set ]
A30: Variable Convert [ Name:%AppTime(3) Function:Seconds to Date Time Store Result In: ]
A31: Variable Split [ Name:%AppTime(3) Splitter: Delete Base:Off ]
A32: Variable Set [ Name:%AppStart3 To:%AppTime32 Do Maths:Off Append:Off ]
A33: End If
A34: If [ %AppTime(4) Set ]
A35: Variable Convert [ Name:%AppTime(4) Function:Seconds to Date Time Store Result In: ]
A36: Variable Split [ Name:%AppTime(4) Splitter: Delete Base:Off ]
A37: Variable Set [ Name:%AppStart4 To:%AppTime42 Do Maths:Off Append:Off ]
A38: End If
A39: Variable Set [ Name:%ShowToday To:1 Do Maths:Off Append:Off ] If [ %NewEvent1 Set ]

Darijo Gospić

unread,
Aug 29, 2015, 5:54:37 AM8/29/15
to Tasker
I've run this task, but I'm getting an error in A20: Variable Convert: %AppTime(1): failed....
Here's my task, maybe you could recognize the error.

Where can I actually see what's the calendar event's name and start time; is it the AppTime (1) and AppStart(4) variables or the %ShowToday variable or what?

Read Calendar (309)
A1: Array Clear [ Name:%NewEvent ] 
A2: Array Clear [ Name:%AppTime ] 
A3: Variable Set [ Name:%time To:%TIMES+28800 Do Maths:On Append:Off ] 
A4: Variable Set [ Name:%stop To:%TIMES+61140 Do Maths:On Append:Off ] 
A5: Variable Set [ Name:%time To:%time+600 Do Maths:On Append:Off ] 
A6: Test App [ Type:Calendar Title Data:%time Store Result In:%newevent ] 
A7: Test App [ Type:Calendar Start (Seconds) Data:%time Store Result In:%apptime ] 
A8: If [ %newevent(#) != 0 ]
A9: For [ Variable:%newevent Items:1:%newevent(#) ] 
A10: Array Push [ Name:%NewEvent Position:999999 Value:%newevent(%push) Fill Spaces:Off ] If [ %NewEvent() !~R %newevent(%push) ]
A11: End For 
A12: End If 
A13: If [ %apptime() != 0 ]
A14: For [ Variable:%push Items:1:%apptime(#) ] 
A15: Array Push [ Name:%AppTime Position:999999 Value:%apptime(%push) Fill Spaces:Off ] If [ %AppTime() !~R %apptime(%push) ]
A16: End For 
A17: End If 
A18: Goto [ Type:Action Number Number:5 Label: ] If [ %time < %stop ]
A19: If [ %AppTime(1) Set ]
A20: Variable Convert [ Name:%AppTime(1) Function:Seconds to Date Time Store Result In: ] 
A21: Variable Split [ Name:%AppTime(1) Splitter: Delete Base:Off ] 
A22: Variable Set [ Name:%AppStart1 To:AppTime12 Do Maths:Off Append:Off ] 
A23: End If 
A24: If [ %AppTime(2) Set ]
A25: Variable Convert [ Name:%AppTime(2) Function:Seconds to Date Time Store Result In: ] 
A26: Variable Split [ Name:%AppTime(2) Splitter: Delete Base:Off ] 
A27: Variable Set [ Name:%AppStart2 To:AppTime22 Do Maths:Off Append:Off ] 
A28: End If 
A29: If [ %AppTime(3) Set ]
A30: Variable Convert [ Name:%AppTime(3) Function:Seconds to Date Time Store Result In: ] 
A31: Variable Split [ Name:%AppTime(3) Splitter: Delete Base:Off ] 
A32: Variable Set [ Name:%AppStart3 To:AppTime32 Do Maths:Off Append:Off ] 
A33: End If 
A34: If [ %AppTime(4) Set ]
A35: Variable Convert [ Name:%AppTime(4) Function:Seconds to Date Time Store Result In: ] 
A36: Variable Split [ Name:%AppTime(4) Splitter: Delete Base:Off ] 
A37: Variable Set [ Name:%AppStart4 To:AppTime42 Do Maths:Off Append:Off ] 
A38: End If 
A39: Variable Set [ Name:%ShowToday To:1 Do Maths:Off Append:Off ] If [ %NewEvent1 Set ]

Matt Vernon

unread,
Aug 30, 2015, 2:18:50 AM8/30/15
to tas...@googlegroups.com

If you look in the variables after running it what's the value of AppTime(1)?

Looking at the task it's a bit of a fudge running all the ifs, it might be better to replace it with a for loop, I couldn't get it to work though and got fed up with it!

MattV

--
Reply all
Reply to author
Forward
0 new messages