JGLI Posted February 17, 2017 Share Posted February 17, 2017 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 More sharing options...
knowitall Posted February 17, 2017 Share Posted February 17, 2017 When does the timer start? make a number variable and set it to 0. Then program when the garage opens +1 when the close -1. Then when that variable changes if >0 turn off tstat if = 0 set to auto And forget the tomer Link to comment Share on other sites More sharing options...
JGLI Posted February 17, 2017 Author Share Posted February 17, 2017 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 More sharing options...
knowitall Posted February 17, 2017 Share Posted February 17, 2017 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 Link to comment Share on other sites More sharing options...
JGLI Posted February 17, 2017 Author Share Posted February 17, 2017 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 More sharing options...
knowitall Posted February 17, 2017 Share Posted February 17, 2017 Sure you are cus both conditionals must be true timer expires left door open nothing happens. Timer expires left door closed right door open nothing happens. Timer expires left door closed right door closed tstat goes to auto Link to comment Share on other sites More sharing options...
JGLI Posted February 17, 2017 Author Share Posted February 17, 2017 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 More sharing options...
knowitall Posted February 17, 2017 Share Posted February 17, 2017 9 lines of code is simpler than 3? Link to comment Share on other sites More sharing options...
eddy.trochez Posted February 17, 2017 Share Posted February 17, 2017 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 More sharing options...
JGLI Posted February 17, 2017 Author Share Posted February 17, 2017 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 More sharing options...
knowitall Posted February 17, 2017 Share Posted February 17, 2017 well you can't program scripts into c4, you program off events so it is what it is. Link to comment Share on other sites More sharing options...
msgreenf Posted February 17, 2017 Share Posted February 17, 2017 but you can create macros and call macros in multiple places which cuts down on progamming Link to comment Share on other sites More sharing options...
JGLI Posted February 17, 2017 Author Share Posted February 17, 2017 thanks. Link to comment Share on other sites More sharing options...
knowitall Posted February 17, 2017 Share Posted February 17, 2017 I don't believe macros would help in this case tho Link to comment Share on other sites More sharing options...
eddy.trochez Posted February 17, 2017 Share Posted February 17, 2017 This is a simple 3 line script to make this work. Am I missing something? The OP had it right the first time, just needs to nest the lines. Link to comment Share on other sites More sharing options...
JGLI Posted February 17, 2017 Author Share Posted February 17, 2017 All good now, just need to get used to the way this work. Thanks for the help. Link to comment Share on other sites More sharing options...
JGLI Posted February 17, 2017 Author Share Posted February 17, 2017 I'm in DFW airport waiting for a connecting flight and was able to test the code (opened the doors, watched thermostat status, etc.). All worked well Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.