1 hour ago1 hr My wife and I decided to take an overnight trip a few days ago so I created this simple program to make the house look "lived in" that night. I set $sOnVacation (a state variable I had just created) to 1 just before we left, and then set it to zero right after we returned. At 10PM that night the lights turned off unexpectedly. It happened again the next night. Since the variable is 0 (zero), why would it do that? There must be something I'm not understanding. Thanks!Look Lived In - [ID 0051][Parent 004E]If $sOnVacation is 1 And From Sunset To 10:00:00PM (same day) Then Set 'Living room lights' On Else Set 'Living room lights' Off
1 hour ago1 hr Well the time interval in your program became false, so it executed the Else statement.
1 hour ago1 hr Author But the variable is zero (I triple checked it), and there is an AND clause between the variable check and the From/To statement, so shouldn't the entire program be FALSE all the time? Why would it still trigger at 10PM?
20 minutes ago20 min What is happening is that at 10pm, the IF clause will get evaluated. Since you are home, the variable is 0, so it executes the ELSE.Think of a time schedule like a variable..if you change the variable, then the IF gets evaluated in any program that has that variable. The clock is like the variable.. when the time is hit, the IF will be evaluated. This is true for any program that has a schedule. The simplest thing to do is to split this into two programs. First one evaluates the variable and if true, it enables the second program that has the schedule in the IF and the then and else as you have it. The ELSE in the first program would disable the second program, so that it doesnt run when you are home. There are many ways to work around what you experiencing.
Create an account or sign in to comment