Schedule time events aren't executing entire piston

bug

#1

For some reason pistons that used the “at every…” timed events are no longer executing the entire piston as a triggered event. In this piston below it used to generate a random time offset at 12:01 AM every day. But when I look at my logs now it never runs the random statements any more. This piston was working up to say the beginning of October this year. Did something change in the piston execution logic for these events or is this a bug. See the example below:

If you look at the log below when the time fired the message for the random number didn’t log and the random number statement didn’t execute:

image

I used this method in many pistons such as looking for offline battery devices, etc.


#2

Why are the tasks outside of the every day statement? With that said, it looks like it will still run since the piston is triggered and will go from top to bottom.


#3

Because it always worked this way, the time is just a trigger just like a device trigger. Any trigger makes the full piston execute. As I stated this worked since April and stopped working earlier in October. Take a look at the log the write to log didn’t happen when the time triggered neither did the variables get set.

There are plenty of examples of people using this approach. The weather alert and battery low example pistons use the same approaches:


#4

I am not aware of anything that changed within webcore recently but my test piston ignored anything outside of the every day statement.

image


#5

Same here, @eibyer. I recently made tweaks to an old piston with a similar structure. It had two every blocks for daily scheduling and the rest of the logic was outside of those blocks. It never ran that outside logic for me, both of my every blocks end with a statement that uses Execute Piston to run the same piston again. So the every block changes a variable then has to call Execute Piston to run the outer logic. The piston was created with that structure last October after testing confirmed that the logic outside the every blocks did not run.

Is it possible that other triggers outside the every caused your pistons to run?

Note that unlike every timers, the on events from block does run through the entire piston.


#6

Here you can see in this trace it marked running though the piston but didn’t run the statements below the time condition:

image


#7

Has anyone figure out what changed / broke on this?

Should it execute the entire piston, or just the block?


#8

I think it has always only executed the block.


#9

Sorry to say but something changed a while back. Look at some of the old pistons. The timed events used to trigger the running of the entire piston. Then after an update (don’t remember the exact date) the only the block executed. Now this could have been a bug fix and we leveraged this “defect” behavior.


#10

We would need an approximate date to see what changed in the code. Based on my own piston discussed earlier it seems that this was behaving as described (running only the timer block) since at least October 2017.


#11

It was between September and October in 2018. I had a block in the piston that would wake up every 24 hours to check battery levels and a few other things. The timer was a block with just a log record to tell me that timer fired. Below is the full piston minus the code I removed. I had the timer near the end and it would re-fire the whole piston:

Here is the piston I had to add to call the above piston above to work around. It’s the same code block I cut out but added the call to run the monitor piston:


#12

Thanks for the details. Here are the changes between the August and the September 2018 releases, the relevant changes are between Aug 13 and Sep 6. Just a few small bug fixes.

I reverted my own webCoRE Piston smart app to version 0.3.106.20180731 but timers still only run the code inside the timer block.

3/30/2019, 6:35:26 PM +119ms
+132ms	║WARNING: Results may be unreliable because the parent app's version (v0.3.10a.20190223) is newer than the child app's version (v0.3.106.20180731). Please consider updating both apps to the same version.
+338ms	║Inside

Something else must have been going on with your pistons, possibly something in the timer block that happened to cause a side effect to trigger the rest of the piston or some peculiarity of the piston structure that causes it to run differently. I can’t rule out some ST platform change but I don’t know if any changes they could make would manifest in this way. I also don’t know enough about the inner workings of piston scheduling and execution to make any guess about what would cause the behavior you were seeing before October.

Just use if time happens at blocks if you still have pistons to convert and if you can express the time in an if. They do behave the way you need.

3/30/2019, 6:43:00 PM +214ms
+125ms	║Outside
+168ms	║Inside

#13

Thank you for the tip on that if statement. I never even thought of that as option. There are just so many ways to implement solutions in WebCore.