Jump to content
C4 Forums | Control4

Multiple if statements...


JGLI

Recommended Posts

Can you have multiple "IF" statements that behave as "AND"? 

I have setup the system so that if either garage door opens the garage thermostat is turned off.  The system is also set so that when a garage door is off, a 5 minute timer starts, after which the thermostat goes back on.  But I want to make sure both doors are closed before it turns on.  I attached a screen shot of the programming with two If statements.  Will this work?

Multipleif.tiff

Link to comment
Share on other sites


Timer starts when the door closes.  I want to make sure that the thermostat doesn't turn back until 5 minutes after both doors are closed.

How does your logic help with multiple If - i.e., taking into account both doors (and the delay).

Link to comment
Share on other sites

3 minutes ago, knowitall said:

Sorry didn't look at picture. Just "nest" the two statements under the first conditional by dragging them onto the ?

shoukdnlook like this

? If ....

        ? If. .....

                -> set to auto

 

3 minutes ago, knowitall said:

Sorry didn't look at picture. Just "nest" the two statements under the first conditional by dragging them onto the ?

shoukdnlook like this

? If ....

        ? If. .....

                -> set to auto

But if you nest them you aren't really getting an "AND" are you?  I need to make sure both doors are closed before I turn on thermostat.  If I nest it, I would need to do it twice, one with one door at the top and the other with the other door at the top (at least in traditional programming).

Link to comment
Share on other sites

OK, so my brain is soft.  I see the logic working.

If Left is closed, and then if Right is closed, then the stat goes to Auto.

My concern was that it wasn't testing for Right, but its irrelevant as if Left is Open it won't turn the stat on.

 

Is there a simpler way to do this?

In normal code i would have written something like this?

If Left is open or Right is Open 

BothDoorOpen := True

End If

If Left Door changes to Closed & Right Door is Closed

BothDoorOpen := False

If Right Door changes to Closed and Left Door is Closed

BothDoorOpen :=False

When BothDoorOpen = False & 5 minute have elapsed, 

Set Thermostat to Auto

 

Link to comment
Share on other sites

9 hours ago, JGLI said:

Can you have multiple "IF" statements that behave as "AND"? 

I have setup the system so that if either garage door opens the garage thermostat is turned off.  The system is also set so that when a garage door is off, a 5 minute timer starts, after which the thermostat goes back on.  But I want to make sure both doors are closed before it turns on.  I attached a screen shot of the programming with two If statements.  Will this work?

Multipleif.tiff

JGLI, your programming is correct, all you have to do is nest all the statements. To answer your question: yes! When you have 2 or more "if" statements nested, they act as "and". But they have to be nested.

Link to comment
Share on other sites

The reason my pseudo code would be easier is that its all on one place.  This is a lot more than 3 lines of code.

You have to setup a timer, go to both dear and create programing for open and closing, and then this snippet which happens to be three lines.

Eddy, thanks for confirming that the nesting of Ifs behaves like "AND".

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.