Trying to figure out a piston using GCal Search (google calendar search)


#1

1) Give a description of the problem
how to trigger piston based on time before Gcal Search Trigger “next openTime”

2) What is the expected behavior?
If time is xx hours before Gcal Search Trigger’s “next openTime”
then
do

3) What is happening/not happening?
Can’t seem to figure out how to program this. I can see the state in webCoRE but I don’t know how to set it up with a if time xx before

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS)

REMOVE BELOW AFTER READING


#2

You have to pull info from the goal event attributes. [eventbame.description] I belive


#3

This may be a little above my skill level. Can you show an example piston using this?


#4

Mobile right now will try to get back to you tonight.


#5

Ok threw this together. It does not subscribe to anything, so you need to just press the test button in webcore fore it to run.

It lists the attributes that are available and fills those in. Then it parses It for motion from what is returned for the attributes to give you some manipulated info from the summary.

From this you should be able to digest the expressions and get started.

All that manipulations to the summary can be found here:

https://wiki.webcore.co/Functions

Hope this helps


#6

Thanks for your example, unfortunately I’m still having a hard time understanding how to do what I want. My goal for the piston is:

if current time is 3 hours before next Gcal trigger event start time and date
then
do
turn on lights

In your example I see how you are using an expression to parse the “eventsummary” although I honestly don’t understand expressions enough wrap my head around it. Since Gcal Event Trigger already has an “openTime” state albeit in UTC time would it not be possible to use that rather than parsing the eventsummary?

If my thought process is inaccurate (which it probably is) would you mind trying to show a specific example to determine three hours prior to the next start time and date? I don’t need the end time for this piston. Also, using your example the parsed date_start is coming up 1 day before what it should be.’

Thanks in advance and sorry for being a NOOB.


#7

Ok… let me see if I can cobble something together for you. The itch time I can’t seem to grab it from the gcal event so we will use the date time thing I showed earlier


#8

This should do it. Tested and works here. Took me longer than thought. I learned a couple new things in process, :blush:. I paired it down from all the other stuff

Contact sensor 5 is your GCal event
White Bulb 4 is your Switch


#9

Let me know if it works for what you want


#10

THANK YOU, THANK YOU, THANK YOU! I’m playing with it now. I’m confident that I would have never figured that one out!

I’ll let you know if I run into any issues post any tweaks I may come up with !


#11

If I want to set the piston state to display the next scheduled trigger time what would be the best way to do this?


#14

looks like I messed something up?

12/8/2017, 7:59:55 AM +466ms
+1ms
╔Received event [gCal Mark Work Schedule Events].eventSummary = Next GCal Event: Work Schedule
+1ms
╔Calendar: Work Schedule
+1ms
╔Event Start: Fri, Dec 08 11:00 AM
+1ms
╔Event End: Fri, Dec 08 11:30 AM
+2ms
╔ with a delay of 121ms
+83ms
║RunTime Analysis CS > 19ms > PS > 42ms > PE > 23ms > CE
+94ms
║Runtime (39650 bytes) successfully initialized in 42ms (v0.2.0ff.20171129) (92ms)
+95ms
║╔Execution stage started
+102ms
║║Cancelling statement #11’s schedules…
+344ms
║║Calculating (error) Invalid parameters. Expecting indexOf(stringOrDeviceOrList, substringOrItem) + (integer) 12 >> (error) Invalid parameters. Expecting indexOf(stringOrDeviceOrList, substringOrItem)12
+348ms
║║Calculating (string) + (string) 2017 >> (string) 2017
+367ms
║║Calculating (error) Invalid parameters. Expecting indexOf(stringOrDeviceOrList, substringOrItem) + (integer) 19 >> (error) Invalid parameters. Expecting indexOf(stringOrDeviceOrList, substringOrItem)19
+371ms
║║Calculating (string) java.lang.ClassCastException + (string) , >> (string) java.lang.ClassCastException,
+373ms
║║Calculating (string) java.lang.ClassCastException, + (string) >> (string) java.lang.ClassCastException,
+381ms
║║Executed virtual command [Scene Mark Wake-up].waitForDateTime (4ms)
+604ms
║║Executed physical command [Scene Mark Wake-up].push() (222ms)
+605ms
║║Executed [Scene Mark Wake-up].push (223ms)
+607ms
║╚Execution stage complete. (513ms)
+608ms
║Setting up scheduled job for Fri, Dec 8 2017 @ 8:03:21 AM AKST (in 205.366s)
+628ms
╚Event processed successfully (629ms)
12/8/2017, 7:58:21 AM +173ms
+1ms
╔Received event [gCal Mark Work Schedule Events].eventSummary = Next GCal Event: Work Schedule
+1ms
╔Calendar: Work Schedule
+1ms
╔Event Start: Fri, Dec 08 11:00 AM
+1ms
╔Event End: Fri, Dec 08 11:30 AM
+1ms
╔ with a delay of 79ms
+360ms
║RunTime Analysis CS > 24ms > PS > 315ms > PE > 21ms > CE
+370ms
║Piston waited at a semaphore for 268ms
+372ms
║Runtime (39718 bytes) successfully initialized in 315ms (v0.2.0ff.20171129) (370ms)
+373ms
║╔Execution stage started
+380ms
║║Cancelling statement #11’s schedules…
+491ms
║║Calculating (error) Invalid parameters. Expecting indexOf(stringOrDeviceOrList, substringOrItem) + (integer) 12 >> (error) Invalid parameters. Expecting indexOf(stringOrDeviceOrList, substringOrItem)12
+495ms
║║Calculating (string) + (string) 2017 >> (string) 2017
+514ms
║║Calculating (error) Invalid parameters. Expecting indexOf(stringOrDeviceOrList, substringOrItem) + (integer) 19 >> (error) Invalid parameters. Expecting indexOf(stringOrDeviceOrList, substringOrItem)19
+518ms
║║Calculating (string) java.lang.ClassCastException + (string) , >> (string) java.lang.ClassCastException,
+520ms
║║Calculating (string) java.lang.ClassCastException, + (string) >> (string) java.lang.ClassCastException,
+527ms
║║Executed virtual command [Scene Mark Wake-up].waitForDateTime (3ms)
+675ms
║║Executed physical command [Scene Mark Wake-up].push() (146ms)
+676ms
║║Executed [Scene Mark Wake-up].push (148ms)
+678ms
║╚Execution stage complete. (305ms)
+679ms
║Setting up scheduled job for Fri, Dec 8 2017 @ 8:03:21 AM AKST (in 299.588s)
+699ms
╚Event processed successfully (698ms)


#15


#16

I think I see it. In that big wit statement, there are four parts that reference [Test Events:EventsSummary]

You need to change that to your GCal event name. So change the Test Events part to your GCal event name. Leave the :EventSummary part alone


#17

ok, I fixed the “test events” issues. But now it seems the piston is triggering the lamp scene everytime it checks for status change.

12/8/2017, 11:58:08 AM +873ms
+2ms
╔Received event [gCal Mark Work Schedule Events].eventSummary = Next GCal Event: Work Schedule
+2ms
╔Calendar: Work Schedule
+2ms
╔Event Start: Fri, Dec 08 10:00 AM
+2ms
╔Event End: Fri, Dec 08 08:00 PM
+2ms
╔ with a delay of 488ms
+375ms
║RunTime Analysis CS > 17ms > PS > 306ms > PE > 52ms > CE
+391ms
║Piston waited at a semaphore for 267ms
+393ms
║Runtime (42467 bytes) successfully initialized in 306ms (v0.2.0ff.20171129) (390ms)
+394ms
║╔Execution stage started
+399ms
║║Cancelling statement #11’s schedules…
+413ms
║║Calculating (integer) 63 + (integer) 12 >> (integer) 75
+416ms
║║Calculating (string) Dec 08 + (string) 2017 >> (string) Dec 08 2017
+424ms
║║Calculating (integer) 63 + (integer) 19 >> (integer) 82
+428ms
║║Calculating (string) Thu, Dec 7 2017 + (string) , >> (string) Thu, Dec 7 2017,
+429ms
║║Calculating (string) Thu, Dec 7 2017, + (string) 10:00 AM >> (string) Thu, Dec 7 2017,10:00 AM
+435ms
║║Executed virtual command [Scene Mark Wake-up].waitForDateTime (1ms)
+1441ms
║║Executed physical command [Scene Mark Wake-up].push() (1005ms)
+1442ms
║║Executed [Scene Mark Wake-up].push (1007ms)
+1444ms
║╚Execution stage complete. (1050ms)
+1445ms
║Setting up scheduled job for Fri, Dec 8 2017 @ 12:03:06 PM AKST (in 296.558s)
+1462ms
╚Event processed successfully (1462ms)
12/8/2017, 11:58:06 AM +245ms
+0ms
╔Received event [Home].time = 1512766686875 with a delay of -630ms
+94ms
║RunTime Analysis CS > 16ms > PS > 35ms > PE > 43ms > CE
+104ms
║Runtime (42165 bytes) successfully initialized in 35ms (v0.2.0ff.20171129) (103ms)
+105ms
║╔Execution stage started
+112ms
║║Cancelling statement #8’s schedules…
+2569ms
║║Executed physical command [gCal Mark Work Schedule Events].refresh() (2454ms)
+2569ms
║║Executed [gCal Mark Work Schedule Events].refresh (2455ms)
+2586ms
║║Calculating (integer) 63 + (integer) 12 >> (integer) 75
+2601ms
║║Calculating (integer) 63 + (integer) 19 >> (integer) 82
+2604ms
║║Calculating (string) Next scheduled shift start: + (string) Dec 08 >> (string) Next scheduled shift start: Dec 08
+2605ms
║║Calculating (string) Next scheduled shift start: Dec 08 + (string) 2017 >> (string) Next scheduled shift start: Dec 08 2017
+2607ms
║║Calculating (string) Next scheduled shift start: Dec 08 2017 + (string) >> (string) Next scheduled shift start: Dec 08 2017
+2608ms
║║Calculating (string) Next scheduled shift start: Dec 08 2017 + (string) 10:00 AM >> (string) Next scheduled shift start: Dec 08 2017 10:00 AM
+2610ms
║║Executed virtual command [gCal Mark Work Schedule Events].setState (1ms)
+2612ms
║╚Execution stage complete. (2507ms)
+2613ms
║Setting up scheduled job for Fri, Dec 8 2017 @ 12:03:06 PM AKST (in 298.017s)
+2629ms
╚Event processed successfully (2628ms)
12/8/2017, 11:53:28 AM +4ms
+0ms
╔Received event [gCal Mark Work Schedule Events].eventSummary = Next GCal Event: Work Schedule
+0ms
╔Calendar: Work Schedule
+0ms
╔Event Start: Fri, Dec 08 10:00 AM
+0ms
╔Event End: Fri, Dec 08 08:00 PM
+1ms
╔ with a delay of 131ms
+67ms
║RunTime Analysis CS > 15ms > PS > 24ms > PE > 29ms > CE
+78ms
║Runtime (42398 bytes) successfully initialized in 24ms (v0.2.0ff.20171129) (76ms)
+78ms
║╔Execution stage started
+84ms
║║Cancelling statement #11’s schedules…
+96ms
║║Calculating (integer) 63 + (integer) 12 >> (integer) 75
+100ms
║║Calculating (string) Dec 08 + (string) 2017 >> (string) Dec 08 2017
+107ms
║║Calculating (integer) 63 + (integer) 19 >> (integer) 82
+110ms
║║Calculating (string) Thu, Dec 7 2017 + (string) , >> (string) Thu, Dec 7 2017,
+111ms
║║Calculating (string) Thu, Dec 7 2017, + (string) 10:00 AM >> (string) Thu, Dec 7 2017,10:00 AM
+116ms
║║Executed virtual command [Scene Mark Wake-up].waitForDateTime (2ms)
+844ms
║║Executed physical command [Scene Mark Wake-up].push() (727ms)
+845ms
║║Executed [Scene Mark Wake-up].push (729ms)
+847ms
║╚Execution stage complete. (769ms)
+848ms
║Setting up scheduled job for Fri, Dec 8 2017 @ 11:58:06 AM AKST (in 278.023s)
+866ms
╚Event processed successfully (865ms)


#18

Here is my latest tweak to the piston (added a piston state showing next scheduled event start time)


#19

I had this too. I will post when I get home. Teaching daughter to drive. New temps today and it’s her time. I did fix though


#20

Ok. Here you go, need to ad a restriction to the on events part of the piston. Only when Gcal event is off . That way it will set the timer for the correct on time for the light.

I believe that should fix it.

[update]. Nope still not right. Sorry. Still working on it


#21

Ok. Had to redo this thing. I think I got it.

2 pistons, one to refresh gCal event every 5 minutes to find any changes to your scheduled calendar event

And one to do the heavy lifting

Again change the test Events part to your gCal event name

Fingers crossed it works as expected

Let me know results. Thanks for being patient

Gopack2


Holiday Piston Community Standard
#22

Seems the calculations for start date are still coming up with yesterday? Even though the start time is showing correctly?

+2ms
╔Received event [gCal Mark Work Schedule Events].eventSummary = Next GCal Event: Work Schedule
+2ms
╔Calendar: Work Schedule
+2ms
╔Event Start: Sat, Dec 09 09:00 AM
+2ms
╔Event End: Sat, Dec 09 06:00 PM
+2ms
╔ with a delay of 118ms
+112ms
║RunTime Analysis CS > 30ms > PS > 53ms > PE > 29ms > CE
+119ms
║Runtime (42624 bytes) successfully initialized in 53ms (v0.2.0ff.20171129) (117ms)
+120ms
║╔Execution stage started
+130ms
║║Comparison (enum) closed is (string) closed = true (1ms)
+131ms
║║Condition #17 evaluated true (7ms)
+135ms
║║Comparison (string) Next GCal Event: Work Schedule
+135ms
║║Calendar: Work Schedule
+135ms
║║Event Start: Sat, Dec 09 09:00 AM
+135ms
║║Event End: Sat, Dec 09 06:00 PM
+135ms
║║ is_not (string) No events found = true (0ms)
+136ms
║║Condition #29 evaluated true (4ms)
+137ms
║║Condition group #1 evaluated true (state did not change) (14ms)
+138ms
║║Cancelling statement #2’s schedules…
+153ms
║║Calculating (integer) 63 + (integer) 12 >> (integer) 75
+157ms
║║Calculating (string) Dec 09 + (string) 2017 >> (string) Dec 09 2017
+163ms
║║Executed virtual command [gCal Mark Work Schedule Events].setVariable (4ms)
+170ms
║║Calculating (integer) 63 + (integer) 19 >> (integer) 82
+175ms
║║Executed virtual command [gCal Mark Work Schedule Events].setVariable (2ms)
+177ms
║║Cancelling statement #25’s schedules…
+185ms
║║Calculating (string) Fri, Dec 8 2017 + (string) , >> (string) Fri, Dec 8 2017,
+187ms
║║Calculating (string) Fri, Dec 8 2017, + (string) 9:00:00 AM AKST >> (string) Fri, Dec 8 2017, 9:00:00 AM AKST
+192ms
║║Executed virtual command [Scene LR Daytime].setState (0ms)
+199ms
║║Calculating (string) Fri, Dec 8 2017 + (string) , >> (string) Fri, Dec 8 2017,
+202ms
║║Calculating (string) Fri, Dec 8 2017, + (string) 9:00:00 AM AKST >> (string) Fri, Dec 8 2017, 9:00:00 AM AKST
+208ms
║║Executed virtual command [Scene LR Daytime].waitForDateTime (2ms)
+421ms
║║Executed physical command [Scene LR Daytime].on() (212ms)
+422ms
║║Executed [Scene LR Daytime].on (213ms)
+423ms
║╚Execution stage complete. (304ms)
+430ms
╚Event processed successfully (430ms)
12/9/2017, 7:43:10 AM +38ms
+1ms
╔Received event [gCal Mark Work Schedule Events].eventSummary = Next GCal Event: Work Schedule
+1ms
╔Calendar: Work Schedule
+1ms
╔Event Start: Sat, Dec 09 09:00 AM
+1ms
╔Event End: Sat, Dec 09 06:00 PM
+1ms
╔ with a delay of 80ms
+64ms
║RunTime Analysis CS > 13ms > PS > 25ms > PE > 26ms > CE
+71ms
║Runtime (42622 bytes) successfully initialized in 25ms (v0.2.0ff.20171129) (69ms)
+72ms
║╔Execution stage started
+83ms
║║Comparison (enum) closed is (string) closed = true (1ms)
+84ms
║║Condition #17 evaluated true (8ms)
+88ms
║║Comparison (string) Next GCal Event: Work Schedule
+88ms
║║Calendar: Work Schedule
+88ms
║║Event Start: Sat, Dec 09 09:00 AM
+88ms
║║Event End: Sat, Dec 09 06:00 PM
+88ms
║║ is_not (string) No events found = true (1ms)
+89ms
║║Condition #29 evaluated true (4ms)
+90ms
║║Condition group #1 evaluated true (state did not change) (14ms)
+92ms
║║Cancelling statement #2’s schedules…
+100ms
║║Calculating (integer) 63 + (integer) 12 >> (integer) 75
+104ms
║║Calculating (string) Dec 09 + (string) 2017 >> (string) Dec 09 2017
+108ms
║║Executed virtual command [gCal Mark Work Schedule Events].setVariable (2ms)
+115ms
║║Calculating (integer) 63 + (integer) 19 >> (integer) 82
+120ms
║║Executed virtual command [gCal Mark Work Schedule Events].setVariable (1ms)
+122ms
║║Cancelling statement #25’s schedules…
+133ms
║║Calculating (string) Fri, Dec 8 2017 + (string) , >> (string) Fri, Dec 8 2017,
+135ms
║║Calculating (string) Fri, Dec 8 2017, + (string) 9:00:00 AM AKST >> (string) Fri, Dec 8 2017, 9:00:00 AM AKST
+139ms
║║Executed virtual command [Scene LR Daytime].setState (0ms)
+147ms
║║Calculating (string) Fri, Dec 8 2017 + (string) , >> (string) Fri, Dec 8 2017,
+149ms
║║Calculating (string) Fri, Dec 8 2017, + (string) 9:00:00 AM AKST >> (string) Fri, Dec 8 2017, 9:00:00 AM AKST
+152ms
║║Executed virtual command [Scene LR Daytime].waitForDateTime (0ms)
+292ms
║║Executed physical command [Scene LR Daytime].on() (139ms)
+293ms
║║Executed [Scene LR Daytime].on (140ms)
+295ms
║╚Execution stage complete. (223ms)
+304ms
╚Event processed successfully (304ms)