Every 15 Min Timer


#1

1) Give a description of the problem
I want something to happen every 15 min of every hour at exactly the 15-min point (0,15,30,45) within 1 piston. Is there an efficient way to specify that?

2) What is the expected behavior?
(PUT YOUR INFO HERE)

3) What is happening/not happening?
(PUT YOUR INFO HERE)

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 THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

Yes… use a timer.

When building a statement, choose timer instead of condition.

But you can’t choose the run time for the every 15 minutes… so you’ll need 4 timers as follows:


#3

Oh…Robin, this is rare… :slight_smile:


How to cancel a timer (invoked using an "every" block)?
#4

I thought of that… but every 60 seconds puts a lot of load on the system and is unnecessary in this situation :wink:


#5

But in this case, every 60 seconds isn’t really going to fire “every 60 seconds”. WC is smart enough to set the Timer to be in 15 minute intervals. So if you look at the countdown clock you will see that it shows 15 minutes to go, not 60 seconds.


#6

It used to run every 60 seconds and log False if ‘only at’ part isn’t met… but that was pre-release and I haven’t tried for a long time, so maybe things have changed.


#7

I’m trying it both ways. Bob’s way give me this log. My goal was to have it fire at 5:30:00. this is off based on when I started it up.

2/26/2018, 5:18:33 PM +453ms
+1ms ╔Starting piston… (v0.3.000.20180224)
+258ms ║╔Subscribing to devices…
+346ms ║║Subscribing to Audio Notification…
+346ms ║╚Finished subscribing (97ms)
+391ms ║Setting up scheduled job for Mon, Feb 26 2018 @ 5:30:33 PM MST (in 719.981s)
+405ms ╚Piston successfully started (404ms)

Robin’s method is giving me 5:30:00, which is good. But I’m struggling with getting the last, do something, block to execute. I made it ASYNC which should make it go whenever the timers tell that piston to run, but it’s not, so I’m now waiting for it to fire so I can capture the trace.


#8

Can you post your current piston?

Who’s bob?


#9

I debugging issue, and I wonder about this. I started this piston about 4 minutes before the 1st time was set to go, but when I started the piston, it set the 1st timer to start 1 hr + 4 min from then. Does that make sense? Why can I catch that up-coming 40 min after the hour rather than at 1 hr and 40 min? Here’s the log.

2/26/2018, 5:37:26 PM +154ms
+1ms ╔Starting piston… (v0.3.000.20180224)
+450ms ║╔Subscribing to devices…
+616ms ║║Subscribing to Audio Notification…
+617ms ║╚Finished subscribing (178ms)
+775ms ║Setting up scheduled job for Mon, Feb 26 2018 @ 6:40:00 PM MST (in 3753.077s), with 3 more jobs pending
+912ms ╚Piston successfully started (912ms)

Here’s the test piston. I’m experimenting with the Never Cancel option to try to get the last block to execute.

Also, I just noticed that the anonymized version of the piston says that media player will play webcore.co at volume 1, whereas I really will be playing track 6 at volume 1. Is that text the way it is supposed to be?


#10

Ouch, sorry Mike. My dyslexic eyeballs saw Bob for some reason.


#11

Every hour will first subscribe to at least one hour ahead so that is normal… it will run hourly at the right times after that.

You don’t need never cancel or async as you don’t have any waits.

The webCoRE.co reference is just because some people might be playing ‘Barbie Girl’ and won’t want to share that lol.


#12

That construct is not working. I created this test piston to try it.

Here is the log.

+0ms ╔Received event [Home].time = 1519705107077 with a delay of -715ms
+181ms ║RunTime Analysis CS > 28ms > PS > 110ms > PE > 44ms > CE
+183ms ║Runtime (36861 bytes) successfully initialized in 110ms (v0.3.000.20180224) (182ms)
+184ms ║╔Execution stage started
+196ms ║╚Execution stage complete. (11ms)
+197ms ║Setting up scheduled job for Mon, Feb 26 2018 @ 9:19:27 PM MST (in 60.518s)
+207ms ╚Event processed successfully (207ms)

The audio device is never called. I took out the ASYNC and Never Cancel. What am I missing? It seems like this should run every min.


#13

Pretty sure you need the WITH statement inside of the Every block. (Just after the do). Drag it up there and try again.


#14

Hmmm… that sucks, I always thought a timer will trigger the rest of the piston to run like a regular trigger does, but you your right, it works like an ‘on events’ block in it’s own little world.

As you are planning 4 timers, save yourself the mess of duplicating the actions 4 times and instead use the execute piston action to execute the same piston.


#15

I could do it with 2 pistons, but I really want just one. So I am doing this. It’s not ideal since I now have 4 places to change if I want to make a change (that might move me to the 2-piston approach later).

But one thing I found is that while I could set the track number with a variable, I could not set the volume with one. WC would not give me the option. And when I selected Variable for that field, I had a red triangle with explanation mark but with no explanation of the problem. So I just hard set it for now.
Ignore this - I set the variable to be an Integer and now all is good.

Here’s my piston.

Separately, is there an example of a piston rescheduling itself that you could point me to? I may try a different approach to the 15-min scheduling problem.