Piston should execute only once when both conditions of an OR are true


#1

1) Give a description of the problem
When both conditions of an OR are true simultaneously, the piston executes twice.

2) What is the expected behavior?
Even though multiple conditions might be true simultaneously, the piston should execute only once.

3) What is happening/not happening?
Piston should send a notification when the aquarium filter is turned off OR the power to the aquarium filter falls below 5W. When the switch to the aquarium filter is turned off, both conditions are TRUE simultaneously and the notification gets sent TWICE. I’ve tried just about every possible way (restrictions, variables, etc.) to prevent this from happening, but all of the methods I’ve used assume the piston runs through when one condition is true before the second condition is true. Since both conditions are true simultaneously, two instances of the piston run each time. The attached was my latest attempt using variables.

**4) Post a Green Snapshot of the piston


5) Attach any logs (From ST IDE and by turning logging level to Full)
(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

hmmmmmm
hi @mooch91
i am not a coder so i am just trying to be set of fresh eyes here:)
one thing I never used and don’t understand is “less than 5W” part?? I don’t understand the difference between less than 5w and OFF… can it be ON but 3W lets say? and what does this mean to the system???

How about something like this…
in both cases your global variable must be FALSE so why not just use that once???

IF {global variable} is FALSE
AND
-----IF Outlet 2 switch is OFF (inside first IF)
---- Then
----Do this do that
----Set global variable TRUE
----IF Outlet swtich 2 is less than 5W (inside first IF)
----Then
----do this do that
----Set global variable TRUE


#3

The reason I did it this way: if the aquarium filter shuts off (power outage, let’s say) and doesn’t prime properly, it actually draws less than 5W. So the switch will appear to be “on” but power consumption is low. This lets me know that the pump isn’t primed and isn’t actually circulating.


#4

I see
It gives me some ideas about my system actually… thank you for explaining…:slight_smile:

so if the the switch is OFF doesn’t that ALSO mean it’s draws LESS than 5W ???
(i am just trying to understand so maybe we can turn this into SINGLE condition piston)


#5

Why not just trigger on power<5W and then do an if to check if the switch is on to determine if this is ok or not primed?


#6

Yes. And when you turn it off with the switch, both conditions are met at the same time.


#7

exactly…That’s why I was trying to understand if I was missing something…

@mooch91 you can just use,

IF Global variable is false
IF outlet switch is less than 5W

this should cover everything.


#8

I’ll tinker some more.

I guess I wasn’t very clear on what I was trying to achieve with this piston. I’m looking for notification every half hour if there is “an issue” with my aquarium filter. One possible issue could be the kids turned it off to feed the fish and forgot to turn it back on. Another could be that it’s running but has leaked or failed to get prime (which has happened following a power outage). So I was really looking for any combination of the switch being off OR low power draw (might even add a high power draw) to send the notification. What’s happening is that some circumstances satisfy multiple conditions in the OR and the message is coming through multiple times. I only want it to come through once until things are back to normal.

I would have thought there has to be a way to get the piston to execute only once when you use an IF-OR. But it’s seeming like if multiple conditions of an OR all happen at the same time, multiple instances of the piston execute simultaneously. The approaches I’ve been taking have been to restrict the piston once it fires, but that doesn’t stop the initial firing of multiple instances of the piston.


#9

I see
well in that case I would say why not create another piston just to see if kids are left it OFF. (I try to avoid complicated pistons and rather use primitive work arounds FYI…)

The second piston could be something like
IF switch stays OFF at least 30 minutes
Then
SMS

or maybe even a timer
Run Every 30 minutes
If switch is OFF
SMS


#10

The real reason is because you have zero triggers in this piston. When there are no triggers in a piston, then every condition you have becomes a trigger… So it will fire off at each event. (notice you have 6 lightning bolts in the left margin)

If you want one alert every half hour (based on the conditions), why not try something like this:

Every 30 minutes  <-- Your one and only trigger
do
IF
    This condition
    or
    That condition
Then
    Send PUSH notification
END IF

IF
    Another condition
Then
    Set variable
END IF
END Every

When it is created, you will no longer see lightning bolts next to your conditions.


#11

Thanks! This works and is the way I finally set it up. I would have liked the monitoring to start only when one of the conditions became true (thought that would have been more efficient), but checking it every so often (half hour in this case) is another way to get the same result.