tome Posted December 12, 2009 Posted December 12, 2009 Sometimes we forget to put the garage door down so I want a program that checks at midnight or so and if the garage door is up, put it down. It should wait for 15-20 seconds, then check to make sure it went down. If not, it should try again, and perhaps one more time. Then give up. Or maybe I will beep my KPL when the next version comes out that supports that. I wrote this program, which I think would work but it doesn't seem very elegant: If From 12:00:00AM To 12:01:10AM (same day) And Status 'Garage-Sensor' is On Then Run Program 'GrarageDoorDown' (If) Wait 20 second Else - No Actions - (To add one, press 'Action') I take it there is not concept of looping (While)? Also, I could decrement a counter but I don't see that either... What other way can I do this, or do you think this is fine? Tome Quote
MikeB Posted December 12, 2009 Posted December 12, 2009 I haven't tested, but how about something like this: If Time is 12:00:00AM And Status 'GarageSensor1' is On Then Repeat 4 times Set 'GarageRelay1' On Wait 20 seconds Else - No Actions - (To add one, press 'Action') Quote
tome Posted December 12, 2009 Author Posted December 12, 2009 I haven't tested, but how about something like this: If Time is 12:00:00AM And Status 'GarageSensor1' is On Then Repeat 4 times Set 'GarageRelay1' On Wait 20 seconds Else - No Actions - (To add one, press 'Action') After the first time it runs, and after the wait 20, does it go back to the If clause or will it just run the Then clause 4 times? If I did that, the garage door would go down, then up, then down, then up.... Tome Quote
MikeB Posted December 12, 2009 Posted December 12, 2009 I haven't tested, but once the sensor goes OFF the IF statement should become false and the program should stop running. Quote
tome Posted December 13, 2009 Author Posted December 13, 2009 I haven't tested, but once the sensor goes OFF the IF statement should become false and the program should stop running. Is there a way to watch a program run like in debug mode, or a log of steps or something? I can watch what happens in the event log but that is just commands issued and recvd, not program steps. Is there something available from the telnet interface? Thanks, Tome Quote
Michel Kohanim Posted December 13, 2009 Posted December 13, 2009 Hi Tome, Unfortunately not ... With kind regards, Michel I haven't tested, but once the sensor goes OFF the IF statement should become false and the program should stop running. Is there a way to watch a program run like in debug mode, or a log of steps or something? I can watch what happens in the event log but that is just commands issued and recvd, not program steps. Is there something available from the telnet interface? Thanks, Tome Quote
jmayzurk Posted December 20, 2009 Posted December 20, 2009 I haven't tested, but once the sensor goes OFF the IF statement should become false and the program should stop running. I just ran into this myself, and it seems strange. It seems that the "if" block is re-evaluted during execution of the "then" block. I have a program like this: IF (backdoor light is off AND garage door sensor is on) THEN { turn on backdoor light turn on some other lights wait 15 minutes turn off backdoor light turn off some other lights } But the everything after the wait statement in the THEN block never gets executed, presumably because a condition in the IF block is no longer true. Is this by design, or is it perhaps a bug? Maybe it's just the old C programmer in me, but it seems like control should remain with the THEN block until it has completed executing. Otherwise there is the possibility of an asynchronous event interrupting my program in the middle of execution and leaving my devices in the wrong state (e.g., projector on but screen still up). In other words, it allows for race conditions. -Jeff Quote
Michel Kohanim Posted December 20, 2009 Posted December 20, 2009 Hi jmayzurk, This is by design and I completely understand the confusion however once you get a hang of it things will fall into place. Unlike procedural programming (like C), ISY is event based. So, anything that causes the condition to become false would cause ISY to re-evaluate the block. The best analogy for this paradigm is multi threaded programming where two (or more) threads are dependent on the value of one variable: if the variable changes, the change is reflected in other threads as well. If you want your programs be base on user actions (such as someone pressing a button) it is best to use Control instead of Status. This way, the program is evaluated IF AND ONLY IF someone does something to the switch AND the event generated is the one you are looking for. i.e. Fast On, Fast Off, On, Off ... With kind regards, Michel Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.