JacquesB Posted June 2, 2009 Posted June 2, 2009 Hi, It took me 3 days and hundreds of door opening / closing, but I finally did it. I finally removed all the races between the programs and the status conflicts... Now, my garage door is managed properly by the program (or programs) next here. My garage door is equipped with a safety mechanism that re-open the door if an obstacle goes under it. Be sure yours have some kind of protection before trying to adapt this program for your needs. I offer this without any warranty : use it at your own risk. Here is my complete garage door management program. It does : 1-Accept Opening / Closing by Insteon Control 2-Accept Opening / Closing by external control (standard remote ; manual switch) 3-Detect if you are coming in or going out 4-Verify the door was closed properly 5-Notify if it was not and try to close it automatically 6-In case of error, retry 3 times with increasing delay between them 7-Confirm the proper closing of the door or Alert if the door can not be closed. My installation is based on : An ISY99i controller, firmware 2.7.0 An IOLinc 2450 v.33 A contact configured as "On" when the door is open and "Off" when the door is closed. A-Create a master folder for everything : Garage Door Management B-In the master folder, create 10 sub folders : DS-0 - Already Closed DS-1 - Opening DS-2 - Is Closed Manually DS-3 - Auto-Close DS-4 - Failure DS-5 - Second Try DS-6 - Third Try DS-7 - Can Not Close DS-8 - Closed OK Variables C-The program uses 11 variables. 2 are KeypadLinc buttons and 9 are programs. The programs used as variables are all saved in the "Variables" folder and are defined as : Var – Door State 0 If Status 'Garage Door - Sensor' is Off Then Wait 2 seconds Run Program 'DS 0 Reset all Door states' (If) Run Program 'LED Management - Came in' (If) Run Program 'LED Management - Going out' (If) Else - No Actions - (To add one, press 'Action') Var – Door State 1 If Control 'Garage Door - Sensor' is switched On Then Wait 2 seconds Run Program 'DS 1 Coming In' (If) Run Program 'DS 1 Going Out' (If) Else - No Actions - (To add one, press 'Action') Var – Door State 2 If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Wait 2 seconds Run Program 'DS 2 Door check' (If) Else - No Actions - (To add one, press 'Action') Var – Door State 3 If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Wait 2 seconds Run Program 'DS 3 Close the door' (If) Else - No Actions - (To add one, press 'Action') Var – Door State 4 If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Wait 2 seconds Run Program 'DS 4 Door problem' (If) Else - No Actions - (To add one, press 'Action') Var – Door State 5 If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Wait 2 seconds Run Program 'DS 5 Door emergency' (If) Else - No Actions - (To add one, press 'Action') Var – Door State 6 If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Wait 2 seconds Run Program 'DS 6 Door Last try' (If) Else - No Actions - (To add one, press 'Action') Var – Door State 7 If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Wait 2 seconds Run Program 'DS 7 Door Cant Close' (If) Else - No Actions - (To add one, press 'Action') Var – Door State 8 If Control 'Garage Door - Sensor' is switched Off Then Wait 2 seconds Run Program 'DS 8 Door Closed OK' (If) Else - No Actions - (To add one, press 'Action') D-Add his own variable as a condition to each folder (No conditions on the master and the Variables) Ex : Folder Conditions for 'DS-0 - Already Closed' If Program 'Var - Door state 0' is True Then Allow the programs in this folder to run. Note : This prevents many races between programs and conflicts between different status. E-Create a program in the master folder for resetting the Garage Door's relay automatically Reset the relay If Status 'Garage Door - Relay' is On Then Wait 3 seconds Set 'Garage Door - Relay' Off Else - No Actions - (To add one, press 'Action') F-Next are the 3 programs in the DS-0 Folder DS 0 Reset all Door states If Program 'Var - Door state 2' is True Or Program 'Var - Door state 3' is True Or Program 'Var - Door state 4' is True Or Program 'Var - Door state 5' is True Or Program 'Var - Door state 6' is True Or Program 'Var - Door state 7' is True Or Program 'Var - Door state 8' is True Then Run Program 'Var - Door state 1' (Else Path) Run Program 'Var - Door state 2' (Else Path) Run Program 'Var - Door state 3' (Else Path) Run Program 'Var - Door state 4' (Else Path) Run Program 'Var - Door state 5' (Else Path) Run Program 'Var - Door state 6' (Else Path) Run Program 'Var - Door state 7' (Else Path) Run Program 'Var - Door state 8' (Else Path) Run Program 'LED Management - Came in' (If) Run Program 'LED Management - Going out' (If) Else - No Actions - (To add one, press 'Action') Note : Do not include State 1 in the IF or it will become true as soon as the door opens and that would stop everything. LED Management - Came in If Status 'Keypad 1 - G' is On And Status 'Keypad 2 - G' is Off And Program 'Var - Door state 1' is False And Program 'Var - Door state 2' is False And Program 'Var - Door state 3' is False And Program 'Var - Door state 4' is False And Program 'Var - Door state 5' is False And Program 'Var - Door state 6' is False And Program 'Var - Door state 7' is False And Program 'Var - Door state 8' is False Then Set Scene 'Keypad 1 - G' Off Else - No Actions - (To add one, press 'Action') LED Management - Going out If Status 'Keypad 1 - G' is Off And Status 'Keypad 2 - G' is On And Program 'Var - Door state 1' is False And Program 'Var - Door state 2' is False And Program 'Var - Door state 3' is False And Program 'Var - Door state 4' is False And Program 'Var - Door state 5' is False And Program 'Var - Door state 6' is False And Program 'Var - Door state 7' is False And Program 'Var - Door state 8' is False Then Set Scene 'Keypad 1 - G' On Else - No Actions - (To add one, press 'Action') Note : The status LEDs tell if you were in (Both Off) or out (Both On). Do not change their status back to a stable state (Both On or Off) before closing the door or the program will get confused between the 2 possibility. You will need 2 scenes, one containing each button, for setting them On and Off. Note 2 : We need 2 variables because should we have only 1, the program that test it and invert it would become an infinite loop reacting to the change it just created. G-Next programs are in DS-1 folder DS 1 Coming In If Status 'Keypad 1 - G' is On Then Set Scene 'Back Home' On Set Scene 'Keypad 2 - G' Off Wait 30 seconds Run Program 'Var - Door state 2' (Then Path) Else - No Actions - (To add one, press 'Action') DS 1 Going Out If Status 'Keypad 1 - G' is Off Then Set Scene 'Keypad 2 - G' On Set Scene 'Leaving' Off Wait 30 seconds Set 'Garage Light' Off Run Program 'Var - Door state 2' (Then Path) Else - No Actions - (To add one, press 'Action') H-Other folders contain only 1 program each. They are : DS 2 Door check If Program 'Var - Door state 0' is False Then Run Program 'Var - Door state 1' (Else Path) Send Notification to All Run Program 'Var - Door state 3' (Then Path) Else - No Actions - (To add one, press 'Action') DS 3 Close the door If Program 'Var - Door state 0' is False Then Run Program 'Var - Door state 2' (Else Path) Set 'Garage Door - Relay' On Wait 30 seconds Run Program 'Var - Door state 4' (Then Path) Else - No Actions - (To add one, press 'Action') DS 4 Door problem If Program 'Var - Door state 0' is False Then Run Program 'Var - Door state 3' (Else Path) Send Notification to All Set 'Garage Door - Relay' On Wait 1 minute Run Program 'Var - Door state 5' (Then Path) Else - No Actions - (To add one, press 'Action') DS 5 Door emergency If Program 'Var - Door state 0' is False Then Run Program 'Var - Door state 4' (Else Path) Set 'Garage Door - Relay' On Wait 3 minutes Run Program 'Var - Door state 6' (Then Path) Else - No Actions - (To add one, press 'Action') DS 6 Door Last try If Program 'Var - Door state 0' is False Then Run Program 'Var - Door state 5' (Else Path) Set 'Garage Door - Relay' On Wait 20 seconds Run Program 'Var - Door state 7' (Then Path) Else - No Actions - (To add one, press 'Action') DS 7 Door Cant Close If Program 'Var - Door state 0' is False Then Send Notification to All Else - No Actions - (To add one, press 'Action') DS 8 Door Closed OK If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Send Notification to All Run Program 'Var - Door state 0' (Then Path) Else - No Actions - (To add one, press 'Action') You can add any other Insteon controller for opening the garage door and the door will be managed automatically by the program. If you wish to have an Insteon controller that opens the garage door AND keeps it open, just add a condition on the master folder and configure your control for setting this condition to a False state. Be sure the state is set back to True by the control that will manually close the door after that. The program structure used here can be re-used for creating any other sequential processing with the event-based interface of the ISY. Also, it can surely be optimized in many ways : reducing the number of programs / of calls / of commands or by moving / removing "Waits". I left it as it is not only because I'm tired of the debug I just did, but also because I think it is easier to follow the program in its sequential logic than in the event-base logic of the controller. Have fun with your installation, Jacques
mike123456789 Posted June 3, 2009 Posted June 3, 2009 WOW! It is too late for me to read that and understand it. I can see why it took 3 days. A little constructive criticism: Why have the door try to close automatically 3 more times if it doesn't close the first time? I think that would be a bit of a safety and property hazard. I know the wife has shut the garage door on her trunk after not pulling in far enough. The safety sensor is too low to the ground to disable the door. They are fairly gentle with their pressure sensing, but it did leave a nice dent and a few scratches, I couldn't imagine the door going back down on it 3 more times (think of what the neighbors would think seeing your rouge garage door beating your car). I use a program that waits 20 seconds and if the door is still open it turns on the KPL that we use as our 'is it open or closed' sensor and you could easily modify it to flash some lights to get your attention. Just a thought, otherwise great job on the programming.
JacquesB Posted June 3, 2009 Author Posted June 3, 2009 Hi, One should not try to have the door closed automatically if their is no security mechanism in place. A detector placed too low is not effective, so the door is not protected. Mine is placed properly and I tested it many times, deliberately trying to close my door while my car was still under it. The controller tries 3 times for different reasons : -Maybe I did not got out of the garage as soon as I usually do and my car itself still block the way. -The obstacle itself can have move (an animal, something moved by the wind, ...) -A person may have been present and cleared the way since ... Of course, the obstacle can still be in place and its the reason I do not try forever. But should something blocks the door, whatever that is, it is still safe because the door will not close on it. Jacques
drglenn Posted August 13, 2009 Posted August 13, 2009 The program looks like just what I need! Just a couple of questions I have to clear up some items I don't understand. The keypad 1 - G and keypad 2 - G are they just status indicators or are they also used to open or close the garage door? I also wondered what is in the "back home and Leaving scenes." You also mentioned that any other Insteon device could open the door and would be managed by the program, how is this done. Thanks for your help, I'm new to this programming stuff and quite lost at times. Having programs as yours really helps the learning process. Glenn
JacquesB Posted August 13, 2009 Author Posted August 13, 2009 Hi, Keypad1-G and Keypad2-G are used to determine if you are at home or not. If you are at home and the door opens, then you are leaving : the program will react accordingly. If you are not at home and the door opens, you are coming back, so again, the program will do what you need. The "Back Home" and "Leaving" are the scenes that define what to do when you come back or leave. Here, "Back Home" include the 2 lights I have inside the garage plus the light at the top of the stairs. "Leaving" includes almost everything so they are all turned off when I leave. The program will manage the door properly no matter what opened it. You can open the door with your standard remote control or a fixed button inside the garage, the management program will respond properly because it is triggered by the fact that the door opens. Should you wish to open the garage door from another Insteon control, just have this Insteon device turn On the IOLinc relay. Here, I have a small program doing just that : If Garage Light is turned Fast On or Garage Light is turned Fast Off Then Set Garage Door Relay On Before using this program, be sure your door has all the safety mechanism installed and working properly. Have fun with your system, Jacques
Recommended Posts