Function / Subroutine?


#1

Is there a way to create function / subroutines?

I have pistons triggered by various sensors in a room, each sensor has its own conditions whether turn on the lights or not.

Turning on the lights also has different conditions based on day of week and time of day etc which i put in seperate piston and use an execute piston from the sensor triggering pistons, so the light piston acts as function.

However it also executes by itself as standalone piston, if the time conditionals are met, the light turns on regardless of sensor pistons. That piston shouldn’t exectute unless it is called from another piston.

So is there a way to add functions/subroutines like that?

It can be resolved with a global veriable but i’d rather avoid dragging global veriables when not neeeded.


#2

You can use the option in the Piston settings to “disable event subscriptions” which should prevent anything in the Piston from triggering by itself.


#3

Found it.
what does “automatic piston state” and “allow pre-scheduled tasks to execute during restrictions” mean?


#4

Piston state is very useful to show info on your dashboard. I’m not familiar with what the other setting does or where it would be useful.


#5

If your piston runs because conditions and restrictions are true but then has to reschedule because of a wait or long fade then later when it reaches the scheduled time your restrictions might not be true anymore. That setting would allow the tasks to complete even though the restrictions are no longer true.


#6

Is this the same as Task Cancellation Policy?


#7

I think they were referring to this setting:

(enlarge pic to see the highlight)

You can access these options by editing a piston, and then clicking on the name of the piston.
(and then the cog wheel)


#8

Stupid question maybe, but do they do the same thing?


#9

Not tested enough to confirm… but I would imagine it is a “beefed-up” version of this:

(which is my preferred method, and unsubscribes to a single trigger)