Jump to content

Help with Program and maybe Wait command


nato595

Recommended Posts

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!

 

post-9016-0-81159500-1517184385_thumb.png

Link to comment

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

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

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.

Link to comment

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.

Link to comment

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

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.

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...