Main

 
Designing my X-10 environment with XTension

The Setup History

My X-10 environment includes over a dozen lamp and appliance modules and a half dozen transmitters / controllers scattered around the house, including a CP-290, all configured to use a single house code. It is focused mostly on convenience and the moderate security you get from randomizing on/off time for lamps. I don't do weather (yet!), major motion detection (yet!) or intense security.

Late in 1997, I decided to convert from a CP-290 controlled using an AppleScript OSAX to the CM-11 under control of Sand Hill Engineering's XTension for the Macintosh. One design goal I had in utilizing XTension was to be able to tell which controllers / transmitters were sending signals. For one thing, when all the lights in the house went out, I was tired of everyone saying, "I didn't hit All Off." With XTension, I saw how I could do this with a level of indirection.

My first design was simply to assign a unique and unused house code to every transmitter, different from the receivers, and with XTension, I would remap each signal to the one house code of all my receivers and the same unit code as transmitted. This way everybody's transmitter would appear to have the same functionality as before, as far as devices controlled. They just had to get used to the no longer immediate response of their controller.

So, in my first XTension database, I defined all the receiver units as installed. Then, I defined units matching all of the signals that each controller could send. This turned out to be somewhat tedious, as every Maxi-controller had to have 16 units defined, all with the same remapping script for each unit code. After I got it all implemented, every controller worked as it had before and now I could tell which controller being used to control lights.

It was then that I discovered a major problem, in that, I had no way to detect the "All On" or "All Off" signal from each controller, and to map it into the one house code. Since this was a primary design goal, I needed some assistance.

The second problem with this design was that if I wanted to change the house code of any transmitter, I needed to go edit sixteen modules to change the house code of their unit assignments and the thirty two scripts, which were logging a message as to which house code controller was making the request.

Thirdly, I discovered that dim and bright weren't working with this design.

Finally, adding a new controller or changing an existing one's house code was very tedious to manage in the database. What I wanted, or thought I needed, was more scriptability in XTension. I wanted to be able to write an AppleScript to generate 16 units for a particular house code and have the On and Off scripts be set appropriately also.

Since this was before I had discovered the XTension discussion list, I called XTension technical support, reached Michael and had a conversation with him. He directed me the to web page on the security console hookup. I went to the web page and studied what was there.

There, I found sketchy documentation on the xtenRxEv event handler. I sat with a Maxi-Controller and a simple copy of the xtenRxEv handler in my Attachments script, that just displayed what signals it saw coming in. I changed house codes on the controller and watched what got displayed until I understood the XTension addressing codes of this handler.

I realized that with the event handler described there, that I could do what I was trying to do in a much easier fashion. That is, since this handler received every incoming event, I realized that I could could detect the "All On" / "All Off" requests and do the house code remapping there, as well as for every unit. This meant that I didn't have to manage lots of units for every controller. In fact I didn't need to define any XTension units for transmitter signals at all. I was now free to reassign transmitter house code at will and without making any database changes, things would work as I desired.

So I threw out my first database and started over. Actually I exported just the receiver units that I had defined and reimported them in to an empty database. I wrote some AppleScript code to decode the 'addr' parameter of the xtenRxEv handler in my Attachments script into a house code and unit code. (Recently this code was vastly improved based on input from the discussion group.) This now works exactly as I desired and is more flexible than my early design. I can now even disallow "All Off" from some controllers.

Follow this link to see some sample XTension log entries from the above design.

To see how this was all put together, follow these links for a detailed description of my Attachments script, Startup Script and other handy Global Scripts.