Help w/ Piston - ALL OF DEVICES


#1

1) Give a description of the problem
Not working as expected

2) What is the expected behaviour?
Turn OFF virtual switch when ALL of the contacts ARE closed.

3) What is happening/not happening?
It’s not doing it. It IS turning ON the virtual device when ANY of the contacts OPEN.

**4) Post a Green Snapshot of the piston


#2

The second IF (lines 25-33) should be moved into it’s own, standalone block at the bottom.


#3

I even tried to move that entire IF block to a NEW PISTON and it simply won’t turn off my virtual switch.

Basically, I’m trying to have an INDICATOR light ON anytime 1 of 10 contacts are open. Once they are ALL closed, I want my indicator light to turn OFF. I have no problem getting the indicator light ON. I’m having a problem turning it OFF.


#4

Your second IF block (lines 25-33) is has been nested within the first one. You need to move it after line 34.

As things stand you are only looking to see if the contacts are all closed if one of them has just been opened.

Oh and you might want to remove the setting of TCP to ‘Never Cancel’ on the IF on line 25. I don’t know what it is supposed to do when set on an IF, but I have seen it cause problems.


#5

I see what you are saying. I moved ALL of the 2nd IF stuff to it’s own PISTON. Still can’t get it to work. What am I doing wrong?


#6

You’ve used ‘change to closed’ instead of ‘are closed’. Only one contact sensor ‘changes to closed’ at a time.


#7

Awesome. Really appreciate the help guys! So I’ve got it working about 75% of the time. However, sometimes my indicator light is TURNING OFF when I just close 1 door and another is still open. It seems to happen after some time. Perhaps it stops “looking” for the other devices after a certain amount of time. Here’s what I have now:


#8

It’s late, so my brain may not be fully connecting, but…

  1. There is not a trigger for the second IF at line 29. Not sure if that matters, since this piston will fire with any change of state of any of the contact sensors.
  2. Are there any other pistons/routines/etc that are acting on your contact sensors?
  3. Everyone here knows that I am a fan of small, task specific pistons. Can you separate this piston into two pistons and see how that works?
  4. I have had some vague, random stuff happening with my ST network recently. So not sure if that could be causing your trouble.

Just food for thought…


#9

I might suggest a slightly different route to avoid multiple triggers:

if any of (contact list) changes      <-- trigger
then
  if any of (contact list) are open     <--condition
    set color to blue
  end if
  if all of (contact list) are closed     <--condition
    turn off
  end if
end if

#10

… and taking @guxdude’s idea a step farther:

IF any of (contact list) changes        <-- trigger
THEN
   IF all of (contact list) are closed  <--condition
      THEN Turn off
      ELSE Set color to blue
   END IF
END IF

This one also has the added benefit of changing colors if there is ever an error with a contact sensor…


#11

You are correct, it doesn’t matter. Any of the contacts “changing to anything” will run thru the entire code.


#12

I like this idea. Will this mess with another Piston I that turns the light RED when Smart Home Monitor is ARMED? It shouldn’t right?


#13

If you are using the same light, whichever happens last will override the color. You could add a check if SHM is on.