Jump to content

Program question/troubleshooting


beninsteon

Recommended Posts

Hi,

 

I'm trying to write a program to notify me if my garage door is open for more than 15 minutes.

 

Here's what I've come up with but it's not working and I'm wondering if anyone can help me troubleshoot:

 

Program 1 [Notification.GarageOpen.1]:

If
        Status  'Outside / System Devices / Garage Door IO Sensor' is On


Then
        Wait  15 minutes
        $GarageOpen  = 1


Else
   - No Actions - (To add one, press 'Action')
Program 2 [Notification.GarageOpen.2]:

 

If
        $GarageOpen is 1
    And Status  'Outside / System Devices / Garage Door IO Sensor' is On


Then
        Send Notification to 'BenInsteon' content 'GarageDoor'


Else
   - No Actions - (To add one, press 'Action')
Program 1 is triggering correctly, but program 2 is not. Despite the variable "$GarageOpen" is 1 and "Garage Door IO sensor" is "On", the console still says the Status is "False".

 

I have a third program that changes $GarageOpen to 0 if the garage closes.

 

Any help would be much appreciated.

 

Thanks,

 

Ben

Link to comment

I approached this problem a bit differently.

 

In a nutshell, my need was similar, but I wanted the ability to have different time delays at different times of the day.

 

So, I structured this as a set of programs, with a variable as the "master control" for it all.

 

1) There's a set of programs that check the status of the door, each one based on a different schedule.  So, the condition for one is something like: if the door has just been opened and it's night time, and the action is to then set the master control variable to 300 (number of seconds I'll permit the door to remain open at that time).  There's a bunch of those.

 

2) There's a timer program.  It runs from 12:03AM to 11:59PM, every 20 seconds (sufficient granularity for me) -- and it's job is to subtract 20 from the value of each master control variable (I have lots of them - two garage doors, ice melters in the winter, block heaters for the tractor, etc).  It checks to make sure that the variable is >0 before it does that, just to avoid silliness (not sure that matters, though).

 

3) Finally, there are action programs for each "master control" variable, these set to trigger on the variable reach zero or less than zero (IIRC).  When that happens, the program sends me emails, or for the ice melters and block heaters it just turns off the scene.

 

By decoupling the bits and pieces into three programs controlled by a state variable, I find I have much more flexibility in determining what and when timers start, what happens when the timer expires, testing the alerts, testing the timers, etc.  It also avoids the oddness associated with "wait" statements inside UDI's programs.

Link to comment

As mentioned above, double-check that GarageOpen is a state variable, otherwise Program 2 won't trigger.

I have a third program that changes $GarageOpen to 0 if the garage closes.


Instead of using a third program, why not put it into the "Else" for Program 1?

Program 1 [Notification.GarageOpen.1]
If
        Status  'Outside / System Devices / Garage Door IO Sensor' is On
Then
        Wait  15 minutes
        $GarageOpen  = 1
Else
        $GarageOpen  = 0
Link to comment

Thanks all for your assistance!

 

I was using an "Int", instead of a "State" var and it is now fixed.

 

@oberkc - I had considered that, but I think that program would simply trigger 15 minutes after the garage is opened, even if it was closed during that period of time.

 

Ben

Link to comment
I had considered that, but I think that program would simply trigger 15 minutes after the garage is opened, even if it was closed during that period of time.​

 

I suspect otherwise.  If the status of the sensor turns off during the wait period, the program will retrigger, evaluating false, and the message will never be sent.

Link to comment

oberkc is correct -- one of the more important idiosyncrasies of ISY programming is condition re-evaluation, it takes a little getting used to the Wait behavior and the difference between state and integer variables.
 

The 'Wait' command, when encountered during program execution, will cause the program's conditions to be reevaluated.
A wait stops when the conditions change.
 
The program's conditions are reevaluated each time a Wait or Repeat statement is encountered, and at the end of each iteration of a Repeat loop.

Therefore, if a Then clause (or an Else clause) contains no Wait or Repeat statements, the entire clause is atomic, and will complete before the program's conditions are reevaluated.

 

Based on the above behavior, this is how I wrote my "Notify Garage Door" program (I use the $GarageOpen state variable in other programs and other notifications):

If
        Status  'Outside / System Devices / Garage Door IO Sensor' is On
Then
        $GarageOpen  = 1
        Wait  7 minutes
        Send Notification to 'BenInsteon' content 'GarageDoor Open'
        Repeat 5 times
            Wait  30 minutes
            Send Notification to 'BenInsteon' content 'GarageDoor Still Open'    
Else
        $GarageOpen  = 0
        Send Notification to 'BenInsteon' content 'GarageDoor Closed'

At the end of each Wait or Repeat, the program condition is re-checked, and if the garage door has closed in the meantime, execution of Then immediately stops short, and Else code (if any) runs.

 

Lastly, if the program is in the middle of a Wait and a change causes the conditions re-evaluate to false, the Wait will end early and the Else code will run immediately.   See above for why this re-evaluation happens with state variables, but not integer variables.

Link to comment

@oberkc I should have known better than to have questioned someone with more than 4K posts! Sorry  :oops:

 

I still get things wrong and continue to learn (or relearn) things here.  Questions are usually welcomed and helpful.  Besides, your question was completely understandable....the wait (and repeat) statements can be tricky until you learn to exploit them fully.

Link to comment

Archived

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


×
×
  • Create New...