Single Large Piston vs. Multiple Small Pistons


#1

Which strategy would be better for operational reliability and performance?

Build large pistons with somewhat related tasks., E.g., One piston that includes routines for managing all of the lights on my property.

Or, create many smaller pistons. E.g., Each piston controlling the lights for a specific area.

I am not concerned about programming complexity or ongoing piston code management. I am more interested in reliability.


#2

I have quite a few large pistons, but I try to limit each one to having only one trigger (or less). While it is possible to have multiple triggers in the same piston, it is important to keep in mind that each time any one of the devices changes (in either direction), the piston runs thru the entire code from top to bottom. (so you will have to code accordingly)

On a related note:
Things that I want to happen on a regular schedule (sunrise/sunset, morning/evening lights, etc) I usually keep inside it’s own piston. (one per event) It is not mandatory, but it streamlines, and makes troubleshooting a breeze.


There are many ways to approach this. I often keep each routine in it’s own piston with no triggers at all. So, for example, I program what I want to happen when I get home all in one piston. (basically, turning a routine into a piston) I have another piston for when I want to watch a movie, and another for when I am heading to bed. By keeping the triggers out completely, then that piston can be called by many other methods. (using my first example, I have another piston that tracks my location, and once that piston determines that I am arriving home, it executes the Welcome Home mentioned above) This also lets me tell Alexa I am going to bed, and she simply executes the Goodnight piston.


It is not always possible, but here’s a good habit to get in:
Try to keep each device trigger to only be subscribed to a single piston. Ideally, when the motion sensor by the front door changes to active, only one piston should be taking action.
(I am only referring to triggers in this paragraph. You can put conditions anywhere)


And lastly, try to not program 20 commands to be sent at the same instant, or you are bound to occasionally get unreliable results.


There are exceptions to every rule, but basically, I prefer many smaller pistons when compared to one mega piston. (unless that mega piston has 1 trigger or less) Reliability drops if too many things are trying to happen simultaneously.


#3

Thank you very much for taking the time to reply.

I was not aware that using multiple triggers in the same piston will rerun all of the code each time one trigger is fired. That would explain some odd behavior I have seen in some of my larger pistons that contain a number of different triggers.

I also have some pistons sending many commands at the same time. Again, another reason I am probably seeing inconsistent results.

I am also sorting out issues with some devices taking different amounts of time to respond to commands, so all of these various issues probably account for a lot of the inconsistencies I have been seeing.

Again, I appreciate your suggestions!


#4

Glad to be able to help.

Your mileage may vary, but I try to keep my simultaneous commands no more than 5 at a time, although I usually do 2 or less. Just for clarification, I may do dozens of commands in the same piston, but I try to avoid cramming them all into one line. I would rather increase reliability, even if it means my code may look a little bloated.


There are other possibilities of course, but one main pattern that I have seen is this often happens when the home network is congested. Much of my advice above is meant to lower the ‘chatter’ as much as possible…