Which Structure is Better?


#1

1) Give a description of the problem
I have a Porch Fountain that runs daily while in season. It only runs when the it’s between the start and stop time and when my wife and I are both home. (Note: The fountain is plugs into an outlet that seasonally also controls Christmas lights. Switch 26 is a Seasonal Flag that allows the fountain to run during ‘Fountain Season’.) The fountain turns off if we both leave and on when either of us is or arrives at home. I’ve been running the first of the pistons shown below and it functions as I expected. However, as I’m re-looking at all of my pistons with an eye toward efficiency, etc. and am worried that it will constantly run (loop) when we are both home. The second piston is my attempt at making things run more efficiently.

So, the question is, which is better? Does it matter? Is there a better way?

2) What is the expected behavior?
I’m sure about the first piston runs fine and I believe that the second one does too (just not positive as it was created this morning). Just looking for a more efficient method and one that’s less of an infrastructure burden.

3) What is happening/not happening?
Both pistons are functionally fine. Just looking for a more efficient method and one that’s less of an infrastructure burden.

4) Post a Green Snapshot of the pistonimage
Original Piston that was running:

I’m specifically worried about line 24. When my wife and I are both home, won’t this just keep re-firing the On command. I know that if the fountain is already on, the piston won’t actually send an ‘On’ command again, but isn’t it constantly firing to see if an ‘On’ command is needed?

Here’s my modified piston that’s currently running:

Thanks for any help


#2

I am a big fan of PRECISE triggers over a 12 hour trigger, so I would definitely choose your new and improved piston above.

With your new piston, it triggers the piston:

  • ONCE a day (9:15am) IF someone is home, Then turn on fountain
  • Any time the last person leaves the house, Then turn off fountain
  • At 35 minutes past @PMOn, Then turn off fountain
  • When the house is empty, and someone arrives home, Then turn on fountain

When you shifted the original code:
“Presence sensor is present”
to:
“Presence sensor changes to present”
you basically pinpointed a precise moment in time for the piston to fire. (this is good)

This is beautifully coded, and should handle all possible scenarios.


#3

Blush! :blush: Thank you!

FYI, It was our conversation about Loops that made me look over this piston (more pistons to review/modify) for efficiencies and infrastructure load reduction. So, thank you twice. :+1:


#4

Glad to be able to help!


#5

Follow-Up:

This piston works as intended - except I’m having an issue with the “changes away from” part (line 59). The result is that the fountain doesn’t turn off when my wife and I both leave the house. I guessing that it’s due to the fact that I have two presence sensors and they cant both be changing to ‘not present’ at the same time? In my earlier piston, that section was written as ‘are not present’ (rather than the current, “changes away from” present. I like the idea of the “changes to” versus “are”, but it doesn’t seem to work.

So the initial question is this: Does “changes to” work with two multiple inputs with different timing? The second questions, if the first question’s answer is no, Any ideas to solve this? How about using “stays not present” or “stays away from” present for 1 minute or something?


#6

When both of you are ‘not present’ do you change the mode.
If so, instead of both of you changing to not present replace with mode changes to away. Or something similar.
Just a thought.


#7

Unfortunately, no. I don’t change the mode. I just turn off a switch that controls a fountain.