How are pistons executed?


This is not a problem but a question of how pistons work.

I see a lot of information on creating your first piston, but I am trying to figure out the execution. Obviously there is an engine created by webcore within ST as a central queueing and execution process (simply stated).

I have seen that pistons can be fired from routines which would indicate that that piston is not being evaluated but rather there to be fired. Another thing I am seeing that the condition is being evaluated before the subsequent piston code is continued. That indicates that the piston is ‘running’ constantly (a certain period) and looking at existing conditions to continue the code. That would imply that this is an ‘active’ piston looking to run rather than ‘inactive’ waiting to be called. Obviously, IFTTT could and probably does exist in both types.

an option is to put in ‘wait’ that could be in either type of piston and put it in a queue that periodically would be checked to see if that wait time was up.

If the two types (active and inactive) exist, how do i set this up?

Piston executes from top to bottom?

Have you see this thread?

Also, if you want a piston to not react to events generated by devices, then set the subscription method to never. You can then just call on that piston from another piston like an ST routine.


Pistons don’t periodically check timers or periodically check conditions.

They subscribe to specific times defined by the piston, and they subscribe to device event notifications, and respond accordingly when the time is reached or an event comes in.


This is personally the way I like to think about them.

You can make pistons which are Event based. That is when an Event happens the piston fires. Such as you come home, the lights come on. Therefore you make a piston which subscribes to the Event of your presence sensor changing to “present”. Then the actions you do are to turn on the lights. This is a very IFTTT type of setup. If this (or this and this but not this) then do that. :slight_smile:

However, you can also make pistons which do not subscribe to any events at all. You can just have pistons that only perform actions and do not have any Triggers in them. You can specifically modify the settings of a piston to turn off all event processing. I do this with several of the pistons that I have and I “call” those pistons from other pistons while passing some “arguments” to them so that they can take action when a different piston Triggers them.

But ultimately something is making a piston run. Whether that is Time or an Event. Otherwise they don’t do anything…


My advice here is to ask a more specific question. What do you want to do… We’ll then tell you the best approach to accomplishing that goal.

You’re right, there’s a lot to learn with WC, but it’s easier to do with some concrete examples rather than with some abstract concepts (trust me on this one). :slight_smile:


Hi, there.

I’ll take you up on your suggestion. :slight_smile:

I’m trying to create a piston that will turn on all my lights 15 minutes before sunset. I want to turn off the lights at different times, depending on the day. For example:

Monday - Friday at Midnight: Turn off Coach Light - Front Door, String Lights
Saturday and Sunday at 2 AM: Turn off Coach Light - Front Door, String Lights
Everyday at 5 minutes after sunrise: Turn off Coach Light - Left, Coach Light - Right

I thought the code I’ve attached would do it, but it didn’t.

This is what I see in regards to when it last ran:

Last executed: 11/14/2019, 7:00:59 AM
Next scheduled: 11/15/2019, 7:02:00 AM

Here is my code:

Any help is greatly appreciated - thanks in advance!