Can I default to Exit after each chunk?


#1

Is it possible to set a piston do default to Exit after each chunk executes? I have a piston with multiple If statements. Each If is intended to be a stand-alone action, and I’ve grouped them into a single piston mostly for organizational purposes. I’d rather not have to insert an Exit statement at the end of each Then.

And a followup question: Exiting doesn’t affect scheduled events, does it?


#2

Depending on your coding, it may be possible, but in general, I try to discourage having a bunch of triggers in the same piston. (the lightning bolts in the left margin)

It is not set in stone, but having multiple triggers in a piston can make simple code much more complex to deal with, and harder to troubleshoot. (and a nightmare with schedules)

I usually code each piston with either zero or one trigger, although I will occasionally use two triggers if they are both the same device.

(For clarity, I may use 20 IF statements in that piston, but they are conditions, not triggers)

Personally, when I am trying to stay organized, I use: Dashboard > Settings > Categories…
Beyond that, I name my pistons: Room Name - Function
Since pistons are listed alphabetically within each category.

Just my two cents.


#3

Thanks for your guidance. I like to organize my logic in larger pistons because I find it easier to debug when I can see the different chunks in one window. And I like to be able to share local variables instead of cluttering things up with lots of global variables. But it is getting tiresome to have to insert exit statements and force subscriptions when I mix conditions and triggers. I’ll give it some more thought.

Still curious if there’s a way to force chunks to exit on a per-piston basis, instead of a per-chunk basis.


#4

I also prefer to organize by device rather than trigger as it is simpler to make sure I am getting the action desired from that particular device (heater, lights, etc). Depending on the sophistication of your logic, if you can use the switch/case statements, the default is to automatically exit after each case. Not sure it is possible for independent if statements but you might be able to take advantage of the automatic cancellation if the piston state changes. Then again, that would still require a statement in each if to set the piston state so it would defeat your purpose.


#5

Learn something new every day…Thanks!!!