palayman Posted December 5, 2020 Posted December 5, 2020 (edited) Finally got around to installing some Insteon switches on the Fans in my bathroom. Created a little program to try and make sure they go off. Here is my simple program. If the light is switched off then it turns off the Fan (whether on or off) 2 minutes later. If the fan is turned on with the light already off, it does the same thing. Or so I thought. Unfortunately it doesn't work. Master Toilet Fan - [ID 0007][Parent 0008] If 'MBR / MBR Toilet Pots' is switched Off Or ( 'MBR / MBR Toilet Fan' is switched On And 'MBR / MBR Toilet Pots' Status is Off ) Then Wait 2 minutes Set 'MBR / MBR Toilet Fan' Off Else - No Actions - (To add one, press 'Action') I suspected some flaw in the If condition, so I split it into two programs and it works flawlessly. Powder Room Fan - [ID 0004][Parent 0008] If 'Powder Room / Powder Room Fan' is switched On And 'Powder Room / Powder Room Lights' Status is Off Then Wait 2 minutes Set 'Powder Room / Powder Room Fan' Off Else - No Actions - (To add one, press 'Action') Powder Room Fan 2 - [ID 000B][Parent 0008] If 'Powder Room / Powder Room Lights' is switched Off Then Wait 2 minutes Set 'Powder Room / Powder Room Fan' Off Else - No Actions - (To add one, press 'Action') Can someone explain the why one works and other doesn't? Is it because the condition is reevaluated when the light which is switched off actually changes status to Off? (I know there are obvious defects in the simple program, Fast On/Off etc.) Edited December 5, 2020 by palayman spelling
MrBill Posted December 5, 2020 Posted December 5, 2020 Waits are interrupted anytime an event happens that causes the IF to be re-evaluated. If you always want the wait and action to occur another method is: Program 1 IF some condition Then Run Program 2 (then) Else (none) Program 2 If (none) then Disable Program 1 wait 2 minutes turn off Enable Program 1 Else (none) Or if you want the time to always be extended, that is 2 minutes from the last activity in program 1 then omit the Disable and enable in program 2.... which will cause the timer to be restarted, by program 1 with more switch activity, but will always eventfully end the 2 minute wait and turn off the device. 1
palayman Posted December 5, 2020 Author Posted December 5, 2020 2 hours ago, MrBill said: Waits are interrupted anytime an event happens that causes the IF to be re-evaluated. Thanks MrBill!
kclenden Posted December 8, 2020 Posted December 8, 2020 On 12/5/2020 at 8:55 AM, palayman said: Is it because the condition is reevaluated when the light which is switched off actually changes status to Off? Mr.Bill's answer seems to have sufficed for you, but for newbies that might read this in the future, the answer is YES and a little bit complicated. The ISY is an event based system, but despite that, two events can't happen at the same time. Your IF statement has three events that can trigger the IF to be evaluated causing either the THEN or the ELSE to execute. Light is physically switched OFF Fan is physically switched ON Status of Light changes (from ON to OFF or OFF to ON) As Mr.Bill says, if any of those events occurs the WAIT is interrupted and the IF is reevaluated. The 3rd trigger is what confuses most people. They see it as a constant state, not an event. And the status is indeed a constant state that can be evaluated at any time, but when the status changes, and only when it changes, an event occurs that causes the IF to be evaluated. So the "And 'MBR / MBR Toilet Pots' Status is Off" acts as both an event which can trigger the IF to be evaluated and as a state which can be evaluated whenever another event triggers the IF. The other two pieces of the IF act only as events. That is to say they are only TRUE when they caused the IF to be evaluated, and whenever anything else causes the IF to be evaluated they will be FALSE. So what is happening with your program is that when you physically switch the light OFF, event #1 above occurs. The IF of the program is evaluated to be TRUE so the THEN is executed and the WAIT begins. Now the ISY changes the status of the light from ON to OFF which causes event #3 to happen. This interrupts the WAIT and when the IF is reevaluated it is FALSE because event #1 happened in the past (remember only one event can happen at a time), event #2 hasn't happen and couldn't occur when event #3 is happening anyway, and thus the ELSE is executed which means the WAIT and subsequent turning OFF the fan never happen. So far we've accounted for what happens when event #1 and event #3 trigger the IF to be evaluated. What happens when event #2 occurs. The IF is evaluated and if the light is ON the ELSE is executed (so nothing happens), but if the light is OFF the THEN is executed which starts the WAIT and then two minutes later the fan is turned OFF just like you want. So key things to remember: As far as the ISY is concerned only one event can occur at a time Statuses create an event when they change (e.g. ON to OFF, 0 to 1, etc), but only when they change. So if your light switch is OFF, and you turn it OFF again no event will occur, likewise if a state variable is 0 and you set it to 0 again no event happens. WAITS and REPEATS will be interrupted and cause the IF to be reevaluated whenever an event within the IF occurs Hmmmm... Got a little wordy. Oh well, this subject is the thing that gave me the most fits when I first started using the ISY so I'll leave it all there in hopes that it helps a someone in the future. 5
Recommended Posts