My Update Blog
Wiring Closet
Main Controller
RS485 Network
Plantation Shutters
Lighting & Devices
Audio System
Climate Control
iPhone Detection
Contact Me
Custom Nodes
Multi-Purpose Node
Servo Controller Node
IR Occupancy Counting
Bed Occupancy Node
Old Townhouse
Old Macros and Events
Old Wiring and Design
Old Lighting and Devices
Old Audio Componets
Old Security System
Old iPhone Web Interface

Washington, NC Real Estate - A cool site with real estate information in Washington, Bath, and Belhaven, North Carolina.

Greenville, NC Real Estate - Another real estate site with information for Greenville and Winterville, NC.

Morehead City, NC Real Estate - Another real estate site with information for Atlantic Beach and Emerald Isle, NC.

Jacksonville, NC Real Estate - A real estate site with information for Jacksonville, NC and Richlands, NC and homes for sale.

Lighting and Devices

I had already chose to go with Insteon as my home automation technology for lighting scenes throughout my old townhouse, so it only made sense to carry over the existing modules and expand it in my new house. MisterHouse has a module that supports Insteon directly so you don't have to write new code to use it.

I have the main controller interfaced with a Dual-Band Insteon PowerLinc Modem (2413S) that connects using a serial cable. It plugs right into a 120-volt wall outlet so that I can send commands over my existing power line to the plug-in lighting devices all over the house. The dual-band model also sends the commands by RF as well for improved range and bridging power phases.


When I went from my old, smaller townhouse to my now much bigger house, I found out quick that MisterHouse didn't have the features I wanted already built in to control my lighting. MisterHouse allows you to control individual lights (and devices) quickly and easily just by running a simple command, for example, $desk_lamp->set(100); will turn the desk lap on to 100% brightness. It will also allow you to create Insteon scenes or groups of lights (and devices) that can be set to all go on, off, or dim to a specified brightness all in sync with one another for a dramatic effect. For example, you can do $family_room_lights->set('on'); and MisterHouse will run the macro causing all the lights to do what I defined when I set that group up.

For a simple setup, the above commands are more than enough to make your house have automated lighting. But I wanted more. I have over 30 Insteon lights and devices in my house with an extremely large, 22ft tall family room that is completely open to the kitchen, dining room, formal living room, and loft areas with no dividers. Let me give you some problem scenarios, starting with the most obvious first:

  • Overriding: If I want to manually adjust a light that is part of a scene, I can't. If the scene/macro is run again, it will adjust the light back to what is defined in the scene template. Not acceptable if I don't want the light changed.
  • Occupancy: What if I want the lighting to change in different rooms based off whether or not the room has a person in it. Sure, it's easy to do if...then... statements for each room, but that gets quite overly complex when you start adding in all the different variables. (see below)
  • Scenes Based on Rules: What if I only want the lights on in the family room if it's dark and there is someone in the room. Sure, that's easy. Now, what if I want them to be on when it's dark, there is people in the room, and if the family room TV is turned on, dim only the light next to it down to 50%. Now what if I want them to be on when it's dark, there are people in the room, and movie mode is on, the TV is on, and no one has walked into the kitchen in the last two minutes then I want them to all be off with exception for the stair lights that need to be on so people don't trip down the stairs. This gets infinitely complex, and believe me when I say I wanted something that is even much, much more complex than this.
  • Scene Transitioning: This is absolutely the most important feature of an amazing automated lighting system. Take the scenario above with the family room again. All of the different lighting combinations have to transition between them seamlessly. If I am in the middle of movie mode, and I want to get in the hot tub, hot tub mode gets turned on. The lights need to be adjusted from their previous states to what I have defined for hot tub mode – all of the lights, not just the ones in my next Insteon scene. If someone gets up in the middle of a movie and goes in the kitchen, the lights need to be adjusted just in the kitchen without disturbing the guests watching the TV. Seamless transitioning is what sets the wow factor in a home automation lighting system.

Software Solution

I developed a solution for all of these problems by creating an event-based lighting system within MisterHouse. Anytime a door is opened, motion detector is triggered, room is occupied, button is pressed, temperature is received, sensor is checked, light switch is manually toggled or dimmed, vehicle is detected, iPhone is detected, audio is turned on in a zone, deadbolt is locked/unlocked, bed is occupied/unoccupied, TV turns on, and any other event based activity in MisterHouse such as time of day, the lighting system is checked.

No where outside the lighting system will you find code that controls a light or device in my MisterHouse setup. The lighting system I built is fully responsible for deciding what lights to adjust, if any, and how to adjust them.

Light Definitions

All of the lights are defined in a very large hash table that defines all the characteristics about them such as what type of device it is, name, location, occupancy condition mapping, can it be locally overridden, timers, groups, and the modes that affect this light along with the order of hierarchy and definitions.

I define my modes in a separate hash table. Each mode has a rule that defines whether it is true or not. For example, I have a mode called “family_tv_on”. The requirement for this particular rule to be true is that the house must be occupied, it must be nighttime, and the family room TV must be currently on. In the light definition hash table, I have another definition of what to do with this light when family_room_tv is true. Each of these definitions will have two sub definitions of how to treat this light depending if the room is currently occupied or if it is empty. Each of these two sub definitions are then further broken down into an actual brightness level that the light should be at, and if I have it designated, what is the name of the Insteon scene group that this light is part of during this particular rule.

The lighting system chooses Insteon scenes, if available, based on whether or not an individual light in that scene is overridden. If that particular Insteon scene does have a light that I have manually overridden, the system can't use it, and must adjust each light individually (they won't transition in sync because of this, but the overridden light will be untouched).

When multiple mode rules are evaluated as true for a light, the hierarchy definition determines which one is selected currently for this light. If there is no mode rule that ends up being evaluated as true, then one of four default rules will be picked by the system. They are DarkOccupied, DarkUnoccupied, DayOccupied, DayUnoccupied. One of these four will be chosen based on whether the system has established it to be nighttime and if anyone is home. Each of these default rules are defined for each light just as the mode rules are. If one of these four default rules is omitted from a light, it is presumed to be off and not part of an Insteon scene.

It gets quite complex. Some of the lights have eight or more mode rules that could be applied, with virtual grouping also taking place depending on what mode rules are evaluated as true for different lights. Individual mode rules can also override the lights default occupancy zones so that lights can be adjusted in different portions of the room based on different times of the day, for example. Timers for motion detectors can also be overridden within a mode rule. For example, I want the lights to stay on for 15 minutes in the family room at night when motion is detected. But when I'm watching a movie, I only want them on for two minutes.

Transition Ordering

Lights are transitioned in an order where when a person travels from one room to another, the room they are traveling to gets its lights adjusted first followed by the lights in the room the person left last. This make automatic occupancy lighting fast and efficient.

Local Overrides

Overrides for lights can also be overridden themselves on “major” scene transitions. For example, when the house changes from occupied to unoccupied, if I had overridden the shower light in the master bathroom for some reason, this particular scene has the privilege to cancel the override and turn it off accordingly. Light overrides can have a time limit defined for each light, and even each mode rule. At the end of each time limit, the light looses its override status and it is adjusted to what it should be at based on the current mode rule. You can also cancel an override on a light by double tapping the paddle switch on or off twice after the override is in effect.

Insteon Communication Wars

Insteon communication wars sometimes happen when you try to send a command to a light too quickly after issuing a previous command to the same light. Sometimes when a light doesn’t respond on the first request, MisterHouse will resend the command up to X number of times. This could take several seconds. 99.9% of the time the light received the original command and executed it, but due to all the other lights transitioning at the same time with all the other Insteon traffic, the response might be delayed a few seconds. For this reason my lighting system also runs a check before adjusting any light or Insteon scene that determines if it was adjusted within the last 10 seconds. If so, it holds off on the new adjustment and waits until 10 seconds has elapsed since the last adjustment before making the new one. There are times when several adjustments might be made to the same light within a 10 second period (hard to explain, but it does happen). No adjustments are made until 10 seconds has elapsed since the first, but the system always keeps track of the last state the light needs to be set to. In other words, when the system finally sends the second command, it will be the correct, up-to-date setting for the light when it is sent.

Beyond Lighting

Although I only mention lights in all the paragraphs above, the lighting system also handles normal devices such as fans, appliances, and even window blinds in the same way as the lights. This makes for a completely automated seamless environment.


Jon Scott 2012 -- All Rights Reserved.