Steve L Posted October 21, 2022 Share Posted October 21, 2022 (edited) I have two light switches and two motion sensors. While either of the sensors detect motion, I want the two switches to be on for two minutes, then turn off. Any new motion resets the time to two minutes. Following the ideas in https://forum.universal-devices.com/topic/37370-interesting-way-of-looking-at-programming-on-isy994/ , I have the following programs: Front Sensor On - [ID 0003][Parent 000E] If ( 'Driveway Motion Sensor / ZW 002 Home Security Alarm' Home Security is Motion (no location) Or 'Walkway Sensor / ZW 011 Home Security Alarm' Home Security is Motion (no location) ) Then Set 'Front Door Switch' On Set 'Driveway Light switch' On $Clock.FrontLights = 3 Run Program 'Timer.Lights' (If) Else - No Actions - (To add one, press 'Action') FrontLights.Off - [ID 0012][Parent 000E] If $Clock.FrontLights < 1 Then Set 'Front Door Switch' Off Set 'Driveway Light switch' Off Stop program 'Timer.Lights' $Clock.FrontLights = 255 Else - No Actions - (To add one, press 'Action') Timer.Lights - [ID 0010][Parent 000F] If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Repeat Every 1 minute $Clock.FrontLights -= 1 Wait 1 second Else - No Actions - (To add one, press 'Action') Turning on the lights is no problem. I can see the variable decrementing to zero, and then... FrontLights Off never runs and the variable continues to decrement. I can manually run the Off program and it does what it is supposed to do, but why doesn't it run when the variable goes to zero? Edited October 21, 2022 by Steve L Link to comment
Solution larryllix Posted October 21, 2022 Solution Share Posted October 21, 2022 Too much complication for the usual and typical triggered light timer.A condensed versionif Motion is switched onThen turn on light Wait 2 minutes turn off lightElse turn off light...this handles some rare cases that other lines in if cause the Wait to be cancelled mis time out.When an if condition is triggered it causes the program to start over. 2 minutes can last forever.Sent from my SM-G781W using Tapatalk 1 Link to comment
Steve L Posted October 21, 2022 Author Share Posted October 21, 2022 Interesting - that's very close to what I had before, that mostly worked, but had some glitches. Let me see if this does what I want - thanks. Link to comment
Steve L Posted October 21, 2022 Author Share Posted October 21, 2022 I'd still like to know, though, why the program wasn't triggered by the variable meeting the condition. Link to comment
Techman Posted October 21, 2022 Share Posted October 21, 2022 @Steve L Are your variables state variables? If not change them to State. 1 1 Link to comment
Steve L Posted October 21, 2022 Author Share Posted October 21, 2022 Ah, I was sure I was missing something. Thanks! Link to comment
tazman Posted October 22, 2022 Share Posted October 22, 2022 @Steve Lyou were running the "if" of a program when you should have run the "then" Run Program 'Timer.Lights' (If) But I don't think that program would ever stop running. Link to comment
Steve L Posted October 22, 2022 Author Share Posted October 22, 2022 The Timer.Lights program did run, and it would have been stopped if the FrontLights.Off program had run. Link to comment
larryllix Posted October 22, 2022 Share Posted October 22, 2022 (edited) 1 hour ago, Steve L said: The Timer.Lights program did run, and it would have been stopped if the FrontLights.Off program had run. Without State variable type usage the program would never trigger. With State variable type usage the program would have triggered, set the variable to 255, re-triggered the program and ran else due to >= 1. (Caused it's own event) However your Then section most likely would have been completed and worked. There are times where lines can get executed ahead of other lines when they are called in different programs. Edited October 22, 2022 by larryllix Link to comment
Recommended Posts