I cant get wait timer to work


#1

1) Give a description of the problem
Hi there, I am brand new to both CoRE and WebCoRE, I love it. However I caint seem to do a basic function of wait 10 seconds and do X. you see what I am trying to do is when a switch named “Start” changes to ON, then wait 10 seconds and turn switch Garden on, if the opposite condition is true then wait 10 seconds and turn Garden off, but it doesn’t work. When I press start, then it turns Garden on immediately. I have tried multiple different ways of doing this with no success.

2) What is the expected behavior?
I expect that after I press the start button on the mobile app that 10 seconds later the Garden switch will turn on and visa versa

3) What is happening/not happening?
When I press start, Garden turns on immediately. When I turn it off it turns off immediately

**4) Post a Green Snapshot of the piston![image|45x37]![image|690x370]

5) Attach any logs (From ST IDE and by turning logging level to Full)
1/19/2018, 10:21:38 PM +462ms
+5ms ╔Received event [Home].time = 1516360899484 with a delay of -1032ms
+159ms ║RunTime Analysis CS > 60ms > PS > 66ms > PE > 39ms > CE
+167ms ║Runtime (36682 bytes) successfully initialized in 66ms (v0.2.102.20180116) (155ms)
+171ms ║╔Execution stage started
+1427ms ║║Executed physical command [Garden].off() (1138ms)
+1428ms ║║Executed [Garden].off (1144ms)
+1430ms ║║Condition #10 evaluated false (1210ms)
+1432ms ║║Condition group #1 evaluated false (state did not change) (1216ms)
+1443ms ║╚Execution stage complete. (1274ms)
+1454ms ╚Event processed successfully (1457ms)
1/19/2018, 10:21:29 PM +359ms
+1ms ╔Received event [Start].switch = off with a delay of 54ms
+81ms ║RunTime Analysis CS > 29ms > PS > 29ms > PE > 24ms > CE
+84ms ║Runtime (36665 bytes) successfully initialized in 29ms (v0.2.102.20180116) (81ms)
+85ms ║╔Execution stage started
+94ms ║║Comparison (enum) off changes_to (string) on = false (1ms)
+96ms ║║Cancelling condition #10’s schedules…
+99ms ║║Cancelling statement #13’s schedules…
+118ms ║║Executed virtual command [Garden].wait (4ms)
+123ms ║║Requesting a wake up for Fri, Jan 19 2018 @ 10:21:39 PM AEDT (in 10.0s)
+143ms ║║Condition #10 evaluated false (52ms)
+144ms ║║Cancelling condition #1’s schedules…
+145ms ║║Condition group #1 evaluated false (state changed) (55ms)
+178ms ║╚Execution stage complete. (94ms)
+191ms ║Setting up scheduled job for Fri, Jan 19 2018 @ 10:21:39 PM AEDT (in 9.936s)
+199ms ╚Event processed successfully (200ms)
1/19/2018, 10:21:23 PM +236ms
+1ms ╔Received event [Start].switch = on with a delay of 59ms
+89ms ║RunTime Analysis CS > 29ms > PS > 27ms > PE > 33ms > CE
+91ms ║Runtime (36670 bytes) successfully initialized in 27ms (v0.2.102.20180116) (89ms)
+92ms ║╔Execution stage started
+101ms ║║Comparison (enum) on changes_to (string) on = true (1ms)
+103ms ║║Cancelling condition #10’s schedules…
+105ms ║║Cancelling statement #11’s schedules…
+121ms ║║Executed virtual command [Garden].wait (4ms)
+125ms ║║Requesting a wake up for Fri, Jan 19 2018 @ 10:21:33 PM AEDT (in 10.0s)
+146ms ║║Condition #10 evaluated true (47ms)
+147ms ║║Cancelling condition #1’s schedules…
+147ms ║║Condition group #1 evaluated true (state changed) (50ms)
+172ms ║╚Execution stage complete. (81ms)
+197ms ║Setting up scheduled job for Fri, Jan 19 2018 @ 10:21:33 PM AEDT (in 9.933s)
+203ms ╚Event processed successfully (203ms)
1/19/2018, 10:21:15 PM +859ms
+1ms ╔Starting piston… (v0.2.102.20180116)
+173ms ║╔Subscribing to devices…
+203ms ║║Subscribing to Start.switch…
+292ms ║║Subscribing to Garden…
+293ms ║╚Finished subscribing (136ms)
+345ms ╚Piston successfully started (344ms)
1/19/2018, 10:17:06 PM +325ms
+4ms ╔Received event [Home].time = 1516360627072 with a delay of -756ms
+150ms ║RunTime Analysis CS > 57ms > PS > 64ms > PE > 34ms > CE
+159ms ║Runtime (36673 bytes) successfully initialized in 64ms (v0.2.102.20180116) (149ms)
+164ms ║╔Execution stage started
+894ms ║║Executed physical command [Garden].off() (638ms)
+895ms ║║Executed [Garden].off (644ms)
+897ms ║║Condition #10 evaluated false (681ms)
+899ms ║║Condition group #1 evaluated false (state did not change) (687ms)
+911ms ║╚Execution stage complete. (751ms)
+923ms ╚Event processed successfully (926ms)
1/19/2018, 10:16:56 PM +956ms
+1ms ╔Received event [Start].switch = off with a delay of 50ms
+73ms ║RunTime Analysis CS > 28ms > PS > 28ms > PE > 18ms > CE
+77ms ║Runtime (36657 bytes) successfully initialized in 28ms (v0.2.102.20180116) (75ms)
+78ms ║╔Execution stage started
+90ms ║║Comparison (enum) off is (string) on = false (2ms)
+91ms ║║Cancelling condition #10’s schedules…
+94ms ║║Cancelling statement #13’s schedules…
+109ms ║║Executed virtual command [Garden].wait (6ms)
+114ms ║║Requesting a wake up for Fri, Jan 19 2018 @ 10:17:07 PM AEDT (in 10.0s)
+123ms ║║Condition #10 evaluated false (38ms)
+125ms ║║Cancelling condition #1’s schedules…
+126ms ║║Condition group #1 evaluated false (state changed) (42ms)
+140ms ║╚Execution stage complete. (62ms)
+145ms ║Setting up scheduled job for Fri, Jan 19 2018 @ 10:17:07 PM AEDT (in 9.972s)
+157ms ╚Event processed successfully (157ms)
1/19/2018, 10:16:49 PM +906ms
+2ms ╔Received event [Start].switch = on with a delay of 58ms
+80ms ║RunTime Analysis CS > 30ms > PS > 33ms > PE > 16ms > CE
+82ms ║Runtime (36662 bytes) successfully initialized in 33ms (v0.2.102.20180116) (80ms)
+83ms ║╔Execution stage started
+101ms ║║Comparison (enum) on is (string) on = true (9ms)
+103ms ║║Cancelling condition #10’s schedules…
+105ms ║║Cancelling statement #11’s schedules…
+121ms ║║Executed virtual command [Garden].wait (4ms)
+126ms ║║Requesting a wake up for Fri, Jan 19 2018 @ 10:17:00 PM AEDT (in 10.0s)
+147ms ║║Condition #10 evaluated true (58ms)
+148ms ║║Cancelling condition #1’s schedules…
+149ms ║║Condition group #1 evaluated true (state changed) (60ms)
+175ms ║╚Execution stage complete. (92ms)
+190ms ║Setting up scheduled job for Fri, Jan 19 2018 @ 10:17:00 PM AEDT (in 9.94s)
+197ms ╚Event processed successfully (197ms)
1/19/2018, 10:16:48 PM +336ms
+4ms ╔Received event [Home].time = 1516360609222 with a delay of -894ms
+283ms ║RunTime Analysis CS > 199ms > PS > 61ms > PE > 28ms > CE
+291ms ║Runtime (36674 bytes) successfully initialized in 61ms (v0.2.102.20180116) (280ms)
+295ms ║╔Execution stage started
+1012ms ║║Executed physical command [Garden].off() (635ms)
+1014ms ║║Executed [Garden].off (640ms)
+1015ms ║║Condition #10 evaluated false (674ms)
+1017ms ║║Condition group #1 evaluated false (state did not change) (680ms)
+1028ms ║╚Execution stage complete. (736ms)
+1038ms ╚Event processed successfully (1040ms)
1/19/2018, 10:16:39 PM +137ms
+1ms ╔Received event [Home].test = 1516360599137 with a delay of 0ms
+48ms ║RunTime Analysis CS > 14ms > PS > 17ms > PE > 16ms > CE
+51ms ║Runtime (36669 bytes) successfully initialized in 17ms (v0.2.102.20180116) (49ms)
+52ms ║╔Execution stage started
+64ms ║║Comparison (enum) off is (string) on = false (2ms)
+67ms ║║Cancelling statement #13’s schedules…
+78ms ║║Executed virtual command [Garden].wait (4ms)
+82ms ║║Requesting a wake up for Fri, Jan 19 2018 @ 10:16:49 PM AEDT (in 10.0s)
+92ms ║║Condition #10 evaluated false (35ms)
+93ms ║║Condition group #1 evaluated false (state did not change) (36ms)
+100ms ║╚Execution stage complete. (48ms)
+106ms ║Setting up scheduled job for Fri, Jan 19 2018 @ 10:16:49 PM AEDT (in 9.98s)
+244ms ╚Event processed successfully (244ms)


#2

Because you are using a ‘changes to’ you may have a conflict here.
When your switch changes to ON, the piston becomes true.
After around 10 seconds, I believe, the piston will change to false as it will look for the switch to change to on again. If it did not do that then when your switch changes to ON again, if the piston had remained true it would not run.
Hope that makes sense.
Try changing from ‘changes to on’ to ‘is on’.
I believe this should work.

Switch changes to ON.
Piston becomes TRUE.
10 seconds.
Piston becomes false as it starts to look for a ‘changes to’ again.


#3

What is turning OFF the switch? Because I think that is the problem. If you look in the logs you will see that the piston receives the event that the Switch turned on and then it sets itself to wake up 10 seconds later to do the next step. However, six (or so) seconds after that, it receives an event that the switch turned off. This same pattern is repeated a couple times in the logs. Something turns off the switch before the piston completes the Wait.

This may be one where you need to modify the Task Cancellation Policy to get things to work…might…but right now you’re not even getting to that point.


#4

Thanks for your help. it was neither of these suggestions. it was just me getting used to how WebCore works. thanks very much for your assistance.