ISY Newbie Posted February 9, 2022 Posted February 9, 2022 I have the program that's supposed to turn on exterior lights when a motion sensor is triggered. But sometimes I'd find the lights stay on for hours long after there has been no motion outside. If Status 'Exterior Sensor' is On Then Set 'Exterior Lights' Fast On Wait 5 minutes Set 'Exterior Lights' Off Else No Action Looking at the log file, the only clue to the problem is that the motion sensor was triggered for a second time within the 5-minute period for the lights to be kept on. Can that second motion trigger somehow have thrown off this program and made the lights stay on for the rest of the night?
MrBill Posted February 9, 2022 Posted February 9, 2022 (edited) 8 minutes ago, ISY Newbie said: Can that second motion trigger somehow have thrown off this program and made the lights stay on for the rest of the night? You need to use "control" instead of "status" in the if statement. With "Status" when the motion detector itself turns off the status is no longer "on" so the "Then" body is abandoned and "else" (which is empty) immediately runs. The then body with "Control" will read "...is switched On" After you've made that change, a second trigger of the motion will start the time over again, once there's no motion for 5 minutes the light will turn off. Edited February 9, 2022 by MrBill
ISY Newbie Posted February 9, 2022 Author Posted February 9, 2022 2 hours ago, MrBill said: You need to use "control" instead of "status" in the if statement. With "Status" when the motion detector itself turns off the status is no longer "on" so the "Then" body is abandoned and "else" (which is empty) immediately runs. The then body with "Control" will read "...is switched On" After you've made that change, a second trigger of the motion will start the time over again, once there's no motion for 5 minutes the light will turn off. Thanks. The conditional statement "If" operates differently than I expected. In all the other programming languages that I've known, the entire "then" block is executed regardless of whether the "if" condition remains true throughout the execution. I'll keep that in mind.
MrBill Posted February 9, 2022 Posted February 9, 2022 7 minutes ago, ISY Newbie said: Thanks. The conditional statement "If" operates differently than I expected. In all the other programming languages that I've known, the entire "then" block is executed regardless of whether the "if" condition remains true throughout the execution. I'll keep that in mind. Correct, ISY program If statements are event based. Anytime a value changes the IF is re-evaluated. The reason "Control" works where "Status" doesn't is Status is reporting On/off/dim level/etc, whereas "control" is just looking for the action "switched on". The other method that you might use when "control" isn't a choice is to link two programs: Program 1: If $state_variable = 1 then run program 'Program 2' (then) ----- Program 2: if (none) then disable Program 1 turn something on wait 1 hour turn something off enable program 1 --------- but if we do that we likely also need a program to make certain Program 2 wasn't running when the ISY restarted--- or in other words to get us to a known state: Program 3: [disabled][run at startup] if $state_variable = 1 then Run program "Program 2" (then) else turn something off enable Program 1 --- program 3 is always disabled but will run at startup if the run at startup flag is set. Disabled means specifically that the IF won't be evaluated, the program does run if called by another program or called by run at startup.
Recommended Posts