I have created this webpage as a small public service to the ISY community. It is my firm belief that a handful of well-documented examples are MUCH more helpful than long tangled threads in the forums, check full of comments which are almost -- but usually not quite -- right.

The Goal -- Monitor and Control Lights in my Basement

I have a large basement, with a large number of lights. I have installed Insteon devices for most of the lights, in part to create handy multi-way switches, but also so that I could easily control the lights from upstairs.

The general idea is that I want to be able, without going downstairs, to:

The most common use of this feature is to easily ensure that all of the basement lights are off, and if not, to turn them off. Another benefit is to be able to turn them all On, which is useful for security reasons, telling all of the teenagers that it is time to go home, etc.

The General Concept

I elected to dedicate a single button on a KeyPadLink to manage the basement lights as described above.
 
The button will have 4 basic services:
 
You can look at the button to see the status of the basement lights:
1. When the button is lit, it means that at least one basement light is on.
2. When the button is off, it means that all of the basement lights are off.
 
You can press the button to turn the basement lights On and Off:

3. If the button is lit (which means at least one light is already on), you can press it, and all of the lights in the basement will turn Off (and the button will turn off).
4. If the button is off (which means that all basement lights are off), you press it, and all of the lights in the basement will turn On (and the button will turn on).

The alert reader will notice that the only way to be sure that all of the basement lights are On is to first make sure they are all Off (that is, the button is Off), then you can press the button to turn all of the lights On.

Four ISY Programs Do All the Work

The heart of the scheme is four simple programs. You should become familiar with this page of Tips & Tricks of ISY Programming before you continue.

Two of the programs are "watchers"; they continually check the status of the lights, and turn the KeyPad button on or off as appropriate.

I named the watcher programs "Basement Set KP LED On" and "Basement Set KP LED Off".

These names are intended to convey the notion that the program "Sets" the light in the KeyPad button on or off, based on the current state of the basement lights. (I realize that the KeyPad buttons are not necessarily lit by LEDs, but that term is descriptive, and helps distinguish the light in the button from the lights in the basement.)

The other two programs are run when you push the button. One runs when you push the button and turn the button on; this program ("Basement Turn All On") turns on all of the basement lights. The other program runs when you push the button and turn it Off; this program ("Basement Turn All Off") turns all of the basement lights off.


 

 

 

Putting It All Together, Step-by-step

1. Housekeeping -- know your devices and scenes

Hopefully you have already established a sane naming convention for your devices, and you have them properly configured and working as expected. Also, make sure that any multi-way device scenes are working as expected.

In the screenshots below, you will see that I have several sets of multi-way switches: "far cans", "light by elevator", "main hall lights", "mirror cans", "steps", and "white globes". The "lanterns" and "bookcase cans" are single switches.

2. Make sure the KeyPad mode is correct

Put the button on your KeyPad into "Toggle Mode". This will cause the button to turn on/off immediately when you press it, which is the way that people expect a switch button to operate. In other words, we want the button to react immediately, even if the basement lights might take a few moments to turn on or off (due to network delays). Thus, to give the user immediate feedback, we want to use toggle mode.

3. Create a scene for all of the basement lights

Create a scene named something like "Basement -- All Lights". This scene should include each device (no scenes, just devices!) that is part of the basement light scheme. They must each be included as a Responder. If you have any virtual circuits (multi-way switches), you need to include each switch in the scene (even if they are not directly controlling the load).

This scene is handy for two reasons. First, it is good programming technique, as the list of devices which comprise the basement lights is kept in one place. Second, it helps you comply with (what I have learned to be) a "rule" of ISY programs, which is detailed in the page on Tips & Tricks of ISY Programming.

4. Create the "Basement Turn All On" Program

This program turns on all of the basement lights by turning the Scene to On, which causes the On command to be sent to the devices. As noted elsewhere, the program does not attempt to manage the scene(s) which control the multi-way switches.

You can probably guess from my naming convention that the KeyPad is located in my bathroom, and that button B is used for the basement.

From the left-hand pane, which shows the list of programs, you can see that I also use this scheme to control the lights in my theater.

Basement Turn All On

5. Create the "Basement Turn All Off" Program

Very similar to the Turn All On program.

Basement Turn All Off

6. Create the "Basement Set KP LED On" Program

This program is a "watcher"; it runs constantly, checking to see if any of the basement lights are On. Note that it tests the status of the devices (not the scenes).

The first test in the If statement checks the state of the KeyPad button (aka the LED).

If the LED is currently Off, then we proceed with the remainder of the If clauses to see if any of the basement lights are On.

Conversely, if the LED is currently On, then we don't need to turn it On again, and thus we want the If to evaluate as false.

If the result of the If expression is true, then we execute the Then portion of the program.

Now pay attention: after pausing for 4 seconds, the If is re-evaluated, and the program only proceeds if the expression is (still) true. While this is not intuitive, it is very useful. And it is the way ISY works.

Re-read the previous paragraph.

Because we have checked the status of the basement lights twice, at 4 second intervals, we can be pretty confident that the lights are in a quiescent state. And because the lights are in a quiescent state, it is a good time to turn the LED (the button) on.

Flicker? Why would the button flicker?
 
If we do not use this check-delay-check sequence, then the button will probably flicker.
 
Recall the 'Basement Turn All Off' program, which runs when the user presses the lit button. As you recall, the button immediately turns off, because it is in toggle mode. So far, this all is working nicely; the user pressed the lit button, and it immediately turned off. And if the user is within sight of the basement lights, s/he sees the lights turning off.
 
But there is more going on! The 'Turn All Off' program set the basement light Scene to Off, which causes the ISY sends a flurry of Insteon commands to the basement devices. This flurry of commands might take a second or two given the chance of network hiccups.
 
So, during the second or two while the basement lights are turning off, what else is happening? Well, the two "watcher" programs are running. Specifically, this program ("Basement Set KP LED On") is running.
 
Without the delay, this program will probably see at least one basement still On, and will thus turn the button light back on! And then a few seconds later, the other watcher ("Basement Set KP LED Off") will probably see that all of the basement lights are Off, and will then turn the button off. And that, my friend, is a flicker.
 
With the delay, the LED On program will probably see at least one light on while the If is processed, but then the program will Wait for 4 seconds -- and then perform the If test a second time. On this second evaluation, the result will probably be false, as all of the basement lights will probably be off after 4 seconds (that should be plenty of time for re-tries and acknowledgements). So, because we tested the second time, the button will remain off. And thus, no flicker. Ahhh, that's better!

Finally, note that the lighting of the button is done through the use of a Scene (again, refer to Tips & Tricks of ISY Programming ).

Basement Set KeyPad LED On

7. Create the "Basement Set KP LED Off" Program

This program is similar to the Set KP LED On program.

The first test in the If statement checks the state of the KeyPad button.

If the LED is currently On (well, not Off), then we proceed with the rest of the If clauses to see if all of the basement lights are Off.

Conversely, if the LED is currently Off, then we don't need to turn it Off again, and thus we want the If to evaluate as false.

If the result of the If expression is true, then we execute the Then portion of the program.

As with the LED On program, we use a 'Wait' statement to cause the If expression to be re-evaluated. Because we have checked the status of the basement lights twice, at 4 second intervals, we can be pretty confident that the lights are in a quiescent state.

Extra credit: the double-check of the lights is not as critical for the LED Off program as it is for the LED On program. Here's why.
 
When the user is turning the lights on using the button, the button will remain lit if at least one of the basement lights has turned on. This seems pretty likely; after all, only one of the basement lights needs to have responded to the Insteon On command in order for the LED Off program to not turn the button off.
 
In the other case, when the user is turning the lights Off with the button, then it only takes one basement light to be slow to respond to cause the LED On program to turn the button back on.

Finally, note that the lighting of the button is done through the use of a Scene (again, refer to Tips & Tricks of ISY Programming ).

Basement Set KeyPad LED Off
 

A final puzzler: why not simply add a Wait statement to the end of the "Basement Turn All On" and "Basement Turn All Off" programs? Wouldn't that provide the time needed for the basement lights to respond to the Insteon commands, and thus be in a quiescent state?
 
Well, this doesn't help. The timing problem is created by other programs running -- specifically the watcher programs. Remember, the watcher programs are also running, in parallel with this program, even while this program is performing a Wait operation. This is the essence of the ISY being a multi-tasking system instead of being a simple single-threaded system -- things essentially happen in parallel.
 
Adding a delay to the Turn All On and Turn All Off programs has no effect on the watcher programs. In order to get the watcher programs to behave, we have to get them to pause and wait for the basement lights to reach a steady-state.


 

November 13, 2010
Copyright (c) 2010 John R. Adams    jra@adamsj.com