nato595 Posted January 29, 2018 Share Posted January 29, 2018 Hello! Trying to make a simple program that sends me an email immediately when a door is opened - easy enough... but the part that is stumping me is that I only want it to send me the email once every 5 minutes, or in other words only if it hasn't already done one in within the last 5 minutes. The reason being that it's not a commonly used door, but occasionally I may go in and out of the door 5 times within a few minutes and I don't want 5 emails. I assumed using the WAIT command after the THEN actions would do this, but I still got an email for every time the door was opened within a short period of time. Also, important note that I don't want the program to only run every 5 minutes, as I do want the email immediately when the door opens, just not excessive amounts of times within a few minutes. Attached is a screen shot of what I have (unworking) as of now. Thanks in advance! Link to comment
stusviews Posted January 29, 2018 Share Posted January 29, 2018 You have no commands after the Wait, so the program will wait 5 minutes and end without doing anything (unless the status changes). Question: do you want the notification if the door is left open for 5 minutes or only if it opens and closes during that time? Link to comment
apostolakisl Posted January 29, 2018 Share Posted January 29, 2018 You will need two programs to do this. program 1 if door is opened then run then program 2 program 2 if blank then disable program 1 send email wait 5 mintues enable program 1 1 Link to comment
KeviNH Posted January 29, 2018 Share Posted January 29, 2018 The "disable" approach is one solution. Another is to use an integer variable, this allows implementation of the solution in a single program: Notify on Shed door open - [ID 0115][Parent 001F] If Status 'Shed Door-Opened' is On And $Integer.Notified_Shed_Recently is 0 Then Send Notification to 'NR' content 'NR Shed Door' $Integer.Notified_Shed_Recently = 1 Wait 5 minutes $Integer.Notified_Shed_Recently = 0 Wait 10 minutes Send Notification to 'NR2' content 'Close the darn shed door already' Else Wait 5 minutes $Integer.Notified_Shed_Recently = 0 Make sure you create the variable $Integer.Notified_Shed_Recently as an Integer, not a State variable, and "Init" is 0 (That is, value starts out as zero after a reboot). Link to comment
apostolakisl Posted January 29, 2018 Share Posted January 29, 2018 (edited) The "disable" approach is one solution. Another is to use an integer variable, this allows implementation of the solution in a single program: Notify on Shed door open - [ID 0115][Parent 001F] If Status 'Shed Door-Opened' is On And $Integer.Notified_Shed_Recently is 0 Then Send Notification to 'NR' content 'NR Shed Door' $Integer.Notified_Shed_Recently = 1 Wait 5 minutes $Integer.Notified_Shed_Recently = 0 Wait 10 minutes Send Notification to 'NR2' content 'Close the darn shed door already' Else Wait 5 minutes $Integer.Notified_Shed_Recently = 0 Make sure you create the variable $Integer.Notified_Shed_Recently as an Integer, not a State variable, and "Init" is 0 (That is, value starts out as zero after a reboot). Just realize that this isn't a controlled wait time. The program can keep retriggering with every change in the status of the shed door and theoretically never send an email beyond the first. Unlikely for that to go on forever, but could easily go for a few hours depending on the usage of that door. Edited January 29, 2018 by apostolakisl Link to comment
larryllix Posted January 29, 2018 Share Posted January 29, 2018 Just realize that this isn't a controlled wait time. The program can keep retriggering with every change in the status of the shed door and theoretically never send an email beyond the first. Unlikely for that to go on forever, but could easily go for a few hours depending on the usage of that door. Good catch! This may be a desirable feature for the OP. Each time the gate is changed open or closed, Else will run resetting the Else timer, effectively making the algorithm 5 minutes after the last gate change the next open will notify. Gate traffic will extend the time. 1 Link to comment
stusviews Posted January 29, 2018 Share Posted January 29, 2018 Good catch! This may be a desirable feature for the OP. Each time the gate is changed open or closed, Else will run resetting the Else timer, effectively making the algorithm 5 minutes after the last gate change the next open will notify. Gate traffic will extend the time. There are no Else statements. Link to comment
MWareman Posted January 29, 2018 Share Posted January 29, 2018 There are no Else statements. I see the Else in the code example... Link to comment
DrLumen Posted January 30, 2018 Share Posted January 30, 2018 (edited) Oops, Nevermind. Edited January 30, 2018 by DrLumen Link to comment
stusviews Posted January 30, 2018 Share Posted January 30, 2018 I see the Else in the code example... There are several examples, I was referring to the OP. I should have been clearer. 1 Link to comment
nato595 Posted January 31, 2018 Author Share Posted January 31, 2018 Thank you all, I appreciate it! I went with the option that APOSTOLAKISL gave in making two programs, as it was the easiest for a newbie like me to understand and duplicate. it's working just as I wanted it to now. Thanks again! Link to comment
apostolakisl Posted January 31, 2018 Share Posted January 31, 2018 (edited) Thank you all, I appreciate it! I went with the option that APOSTOLAKISL gave in making two programs, as it was the easiest for a newbie like me to understand and duplicate. it's working just as I wanted it to now. Thanks again! Others have expressed some concern that should ISY reboot (a power failure) during the 5 minutes, then your program 1 will be stuck disabled. Should you choose, you can fix this pretty easily Program 1 If door opens Then Run Else program 2 Program 2 - set this to "run at startup" If - blank Then enable program 1 Else Disable program 1 Send email Wait 5 minutes Enable program 1 Now, on the program summary page, set program 2 to RUN AT STARTUP Run at startup will trigger the if clause at startup. In the case of a blank if clause, then it defaults to running the then clause. So, basically, program 1 will be enabled at startup. Edited January 31, 2018 by apostolakisl 1 Link to comment
Recommended Posts