Can I use is open or do i need to use changed to open


#1

this is just a general question about piston design as I am a new user. I set up a piston that will turn a light on in my garage if either of two contact sensors are open.

my question is for the condition, can I say if the contact sensor “is open” - or do I have to use “changed to open”


#2

I am by no means an expert, but through playing with pistons a bit and thinking through the logical process I think I can answer. If the only thing you want to affect if the lights come on is the doors opening, then I would use “changed to open”. You want the lights to come on when the door opens, so you use the “changed to” as that is the point in time when the door goes from closed to open. Using “is open” doesn’t actually give you a specific trigger event…it can be open indefinitely.

If you are using the doors being open as a condition and something else as trigger, say when the doors are open and an arrival sensor shows someone arriving, then turn on the lights, you would use “is open”. In that situation, the trigger would be the arrival of someone, but it will only trigger if the door is open.

Please, others, correct me if I’m wrong.


#3

The answer to that is in this link… But it depends on how you’re creating the piston how WC is going to execute it.


#4

thanks for the replies - i THINK I understand a little better now. I attached a snapshot of my modified piston - let me know if you think this looks better:


#5

I think you can make this a little more streamlined…

  • I don’t think you need an Else statement in your first IF. That’ll never execute because it’s based on a trigger. “if a trigger doesn’t happen then do something” doesn’t make sense.
  • For the second part “if a contact closes and the other one is already closed then turn off” you can probably wrap it all into one statement. IF (contact 1 OR contact 2 changes to closed) AND contact 1 and contact 2 are closed THEN turn off the dimmer.

That said - pretty sure it’ll work as intended the way it’s written, just could be a little more concise.

In fact, could be written as if contact sensor 1 or 2_changes_ instead of changes to.
if 1 or 2 changes then
if 1 or 2 is open
turn on
else
turn off


#6

just to clarify - what I am trying to accomplish is this:

I have two doors to my garage with contact sensors on them and a light fixture with a smart bulb.

I am trying to make it so that if either of the two doors is opened, the light turns on.

I also want it so that the light only turns off if BOTH of the doors are closed.


#7

thank you - that is definitely more concise - I will give that a try.


#8

ok so hopefully this is a bit better… only remaining question is how do I remove the else from an if statement?


#9

Looks great to me. You do know you can put multiple devices in one statement, and don’t have to add a condition or trigger for each? See the difference between yours (one line for each contact sensor) and mine (one line for both)?

And for the else statement - I just ignore them. I don’t think you can delete them thoughyou can hide them.

Milhouse


#10

great to know - thank you!


#11

No sure about this millhouse, but your statement that if any of the sensors contact is open… turn on, the else part won’t work the way he wants it to? Logic for the way I am reading is: if any is open Tuen on, else if any is closed turn off. I think he wants them to be both closed in order to execute the turned off action?


#12

I think it works. The only way the ELSE part gets run is IF ANY is Open evaluates to false, and the only way an “IF ANY” can be false is if all of them do not meet the condition.

The way I see it is that the opposite of “if any” is “none”.

So the way I read it is, IF ANY are open turn the light on, if none are open Turn the light off.


#13

And remember the trigger is if one of the sensors CHANGES. So…
Something changed
If at least one sensor is now open turn on (or leave on) the light.
If neither sensor is open turn off the light.