Still unclear how commands AND, OR, BUT are created when building piston


#1

I still can’t understand how to distinguish AND OR and how to create BUT IF

Another bathroom (Robin did for me the first webCoRe piston for the Main bathroom THANK YOU !), and this time I like to do it my self. Before I used CoRe and created separate pistons for the Light and Fan.
I presume it should be possible to have it all in one piston so trying to do it now.

Plan is to have the bathroom light turn ON on motion, and after 3 minutes of no motion OFF
BUT IF the shower door closes, motion sensor will be disabled light will go to 100%, fan will turn ON
(Both Light and Fan will be on 30 min timer OFF if the door stays closed , ideally the light will resume ON/OFF function using the motion sensor if the shower door stays closed)
Once the shower door opens, motion light resumes its function on previous intensity level (didn’t find way to incorporate that in my attempt) and fan will turn off after 7 minutes

Well, it was complicated to describe not to mention create the piston that would work :thinking:
Below is my attempt


#2

I would suggest that you start using some variables to keep track of current state of things in this piston. That way you can refer back to those and take the appropriate action as needed.

So if you make a Boolean (True/False) variable called (anything really…but for the sake of the example) AutoOff and set it to True on Motion. If AutoOff stays true, then you turn off the light. But if (ha…) the shower door closes, then you flip the value of AutoOff to False. Then later in the piston you test…is AutoOff True or False…cause if it’s true then you should turn off the light, but if it’s false do something else.

Then at the end of the piston, just set the value of the variable back to the False state so that it’s ready for the next run through.

You can also make a piston with separate Triggers all at the root instead of nesting all the IF’s and using Else statements and such. Sometimes it’s just easier to design them that way for readability. Functionally if would not be much different than what you’ve got going so far…as you are nesting full IF blocks anyway.


#3

Thanks for those suggestions Mike, will try again.


#4

Mike, could you point me to some simple example of piston that is using variables?


#5

Several examples in here…


#6

That’s great, somehow missed that.
Thanks you for being so helpful!