Jump to content

Reset variable with program 1 One hour after Programs 2 and 3 etc finish running


Recommended Posts

Posted

I have Spent a good part of this afternoon trying to see if this is possible.  This is my problem.  I have 10 programs that can update the same integer variable.  What I want to do is reset this integer variable back to 0, one hour after this variable equals 2. 

So I was thinking I could accomplish this one of two ways.  I am running Firmware 5.3  

A.  Reset the variable with a program that runs based on the last time one of these ten programs have run, or

B.  Reset the variable back to 0 with a program that runs every hour.  This is easily done but puts some error in the purpose but I may have to do it this way. Or 

C.  Reset the variable based on the last time it was equal to 2.

I don't think it is possible to do it with option C.

I have searched the drop downs and I cannot find a way to do this checking when the last time a program has run.  I thought I had done something like this in the past.

Background, I have 10 motion detectors that each have a program that updates this variable.  These programs send an email notification that there is motion but I only want two emails for any activity around these 10 motion detectors.  But after a time delay I want to set the variable back to 0.

Would appreciate any thoughts or suggestions 

Thanks

Note:  I am always feeling like I am always asking but unfortunately my technical skills and programming is pretty limited to provide much help to others  

 

 

 

 

 

 

Posted (edited)

Option C is possible as long as you are using a State Variable.

The trick is if the variable might change while we are waiting the hour then you need two programs.

In the simplest form:

aaaa test - [ID 00E8][Parent 0001]

If
        $stemp_test is 2
 
Then
        Wait  1 hour 
        $stemp_test  = 0
 
Else
   - No Actions - (To add one, press 'Action')

will reset the variable to zero after an hour.  the problem is if the variable CHANGES during the hour the timer is stopped and we never reach the $stemp_test = 0

If It's possible that the variable might change you could use Two programs like this:

aaaa test - [ID 00E8][Parent 0001]

If
        $stemp_test is 2
 
Then
        Run Program 'bbbbtest' (Then Path)
 
Else
   - No Actions - (To add one, press 'Action')

 

bbbbtest - [ID 00FE][Parent 0001]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        Disable Program 'aaaa test'
        Wait  1 hour 
        $stemp_test  = 0
        Enable Program 'aaaa test'
 
Else
   - No Actions - (To add one, press 'Action')

Option A is also possible, but Option C using a state variable is likely the simplest way.

Option B doesn't sound like what you want to accomplish anyway.

Edited by MrBill
  • Like 1
Posted

Re-reading your first post again, Option C is definitely what you want, change to using a State Variable, and use the two program method.

Then with your program that sends the notification you'll want to use

If

    $stemp_test <= 2

then

   send notification.

Posted

Mr. Bill. Thank you.  I never thought of using a state variable.  The variable will not change once it reaches two so the simplest method works. 

I will start fresh in the morning and change my variable to a state variable.  Sometimes you get so involved in thinking one way that you miss other alternatives.  As I am writing this I see how easy and effective this will be.  

Thank you. 

Posted (edited)
5 hours ago, MrBill said:

Option C is possible as long as you are using a State Variable.

The trick is if the variable might change while we are waiting the hour then you need two programs.

In the simplest form:

aaaa test - [ID 00E8][Parent 0001]

If
        $stemp_test is 2
 
Then
        Wait  1 hour 
        $stemp_test  = 0
 
Else
   - No Actions - (To add one, press 'Action')

will reset the variable to zero after an hour.  the problem is if the variable CHANGES during the hour the timer is stopped and we never reach the $stemp_test = 0

If It's possible that the variable might change you could use Two programs like this:

aaaa test - [ID 00E8][Parent 0001]

If
        $stemp_test is 2
 
Then
        Run Program 'bbbbtest' (Then Path)
 
Else
   - No Actions - (To add one, press 'Action')

 

bbbbtest - [ID 00FE][Parent 0001]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        Disable Program 'aaaa test'
        Wait  1 hour 
        $stemp_test  = 0
        Enable Program 'aaaa test'
 
Else
   - No Actions - (To add one, press 'Action')

Option A is also possible, but Option C using a state variable is likely the simplest way.

Option B doesn't sound like what you want to accomplish anyway.

Cool thing about variable logic is, it eliminates the multiple hits triggers from that variable. If all triggering programs all set the variable to the same value (=2 = no change in value)  the program to reset it will never see more than the first "hit " (value = 2) no change in value

This means the second program to lock out the "reset timer" program would not be necessary as it can free run using a variable.

Variables do not play exactly the same logic as device events do. Good for "once and only once" style logic.

Edited by larryllix
Posted
15 hours ago, LarryCRetired said:

Mr. Bill. Thank you.  I never thought of using a state variable.  The variable will not change once it reaches two so the simplest method works. 

I will start fresh in the morning and change my variable to a state variable.  Sometimes you get so involved in thinking one way that you miss other alternatives.  As I am writing this I see how easy and effective this will be.  

Thank you. 

Larry,

Let us see the program that the 10 motions are using (or one of them if it's 10 similar programs).  My concern is that if you are using your Integer variable as part of the IF statement (to prevent it growing larger than 2) that we have effected that program with the change to state variable. 

In general, State Variables and Integer variables are very similar.  However State variables can be used as a Trigger in an If statement, Integer variables can only be used as a Filter in an If statement.   State variables can also be a filter, but there can be adverse side effects if there is an Else statement.  (that's a lot of complicated thoughts reduced to 2 sentences!)

  • Haha 1
Posted
11 hours ago, larryllix said:

Cool thing about variable logic is, it eliminates the multiple hits triggers from that variable. If all triggering programs all set the variable to the same value (=2 = no change in value)  the program to reset it will never see more than the first "hit " (value = 2) no change in value

This means the second program to lock out the "reset timer" program would not be necessary as it can free run using a variable.

Variables do not play exactly the same logic as device events do. Good for "once and only once" style logic.

Except he's counting with the variable... its appears he's limited it to 0, 1, 2 but I'm not sure yet how that was accomplished.

Posted (edited)
4 hours ago, MrBill said:

Except he's counting with the variable... its appears he's limited it to 0, 1, 2 but I'm not sure yet how that was accomplished.

I thought the value of 2 was a little odd, but we haven't seen an originating program yet.

On that note: I was using value 2 to initiate "request for voice output" via ISY Portal to Alexa speakers in 30 second spacing arbitration programs. BTW: That didn't work because ISY Portal issue  a "not true" logic to Alexa routines which causes a 30 second lockout and then the value 1 failed each time.

Edited by larryllix
Posted

larryllix

Mr Bill has been helping me directly.  I am using the value of two because I was trying to limit my notifications.  Mr Bill worked out an elegant process to use a state variable which increments and the when it reaches two, resets my counters after an hours wait. 

My previous experience has been mainly with integers.  I think I saw where you have upwards of five hundred.  I just have half as many. 

Posted (edited)
3 hours ago, LarryCRetired said:

larryllix

Mr Bill has been helping me directly.  I am using the value of two because I was trying to limit my notifications.  Mr Bill worked out an elegant process to use a state variable which increments and the when it reaches two, resets my counters after an hours wait. 

My previous experience has been mainly with integers.  I think I saw where you have upwards of five hundred.  I just have half as many. 

I try to keep my state variables to a minimum due to possibly slowing ISY down. I do admit I use some for titling groups of variables.

However I do use Integer variables for constants also and that takes lots, but they do not invoke events when they change, and are a cheap resource for ISY. eg. $cTRUE is permanently =1, $cFALSE is permanently = 0, $cROOM.GATHRM = 21, $cROOM.RECRM = 11, $cMODE.DIM = 4 etc... This saves me looking up values for things as well as text messages containing the room number for MSes and LDs (always includes a room chart also)

Edited by larryllix
Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.4k
×
×
  • Create New...