I have been working on various home automation projects:
The output from my PC sound card goes into my stereo receiver so that I can play music files. I use the Windows Media Player ActiveX control which is part of the Windows Media Player SDK. To control the media player via remote control and through automation, I installed the cm11a X-10 interface and wrote a program called The Lurker which responds to incoming commands and events.
The system maintains a circular list of playlists. X-10 commands trigger selecting the previous or next playlist, going to the previous or next track in the current playlist, and pausing or resuming play. I store my playlists in .m3u files because .m3u files can be a simple list of .mp3 file names without any tags or structure. A simple command line (for /r %i in (*.mp3) do echo %i>>"%cd%.m3u") can be used to generate a playlist for each set of .mp3 files in the subdirectories of a given path.
When I had only a couple dozen playlists, having commands to move to the previous and next playlists worked reasonably well. Later when I had over 200 playlists organized by artist it was too unwieldy to try to get to a particular playlist by stepping sequentially. I added commands to jump ahead 1/8, 1/4 and 1/2 of the way through the list of playlists. The playlists are in alphabetical order but when jumping to a playlist 100 positions ahead in the ordering it is sometimes not immediately apparent what artist is playing without advancing through several songs in the playlist until finding something familiar. This can make for an interesting party game but is too slow for finding a particular playlist quickly. I installed the Microsoft Agent so that I could use the text-to-speech feature to identify a newly selected list by speaking the name. I also came up with a scheme for mapping the letters of the alphabet to the keys on the remote control and implemented an incremental playlist search function. As each letter is typed the name of the first matching playlist is spoken.
I have a DSL internet connection and I set up a web page for sending X-10 commands. I discovered that when The Lurker service was running, the web page could not send commands to the X-10 interface on the COM port. This was caused by the COM port being tied up. There is probably an elegant way to get the Windows service and web page to share the same COM port but I found a different workaround. I had a cm17a interface lying around so I hooked it up to a different COM port. The cm17a can only send X-10 commands but for the web page that is all that is needed.
Router Power Cycling
I enhanced the X-10 Lurker service to detect and deal with a hung router. I have seen my router go into an unresponsive state where I was only able to restore connectivity by cycling the power. This happened only once after months of uptime but to prevent it from happening again, I now have my router plugged in to an X-10 module. Every 10 minutes, the X-10 service running on my computer pings the IP gateway. If there is no reply, the program then tests the connection four more times at 30-second intervals. If there is still no connectivity, the system will then power cycle the router.
I use the Windows Task Scheduler to run automation commands at set times. There is probably an elegant way to get the Task Scheduler to send notifications to the Lurker service when there are jobs to be run. Instead, I have my scheduled tasks append a line to a text file that gets read periodically by the Lurker. The scheduled tasks need not be aware of the actual X-10 command that is to be executed. Instead, the Lurker expects devices to be referred to by their human-friendly names listed in the registry.
Right now the chief uses I have for task scheduling are:
Poor Man's Fade-on/Fade-off
X-10 lamp modules support the Preset Dim command which allows you to have a light turn on at specific level of dimming. Unfortunately, many lamp modules will first turn on the light at full power and then will fade back to the preset dim level. Fancy switches such as the Leviton model 2203 will correctly bring the lights up to the desired level of dimming. Of course, I only have the cheaper lamp modules. The way to get around the problem is to fade lights to the 0% dimming level instead of sending them an X-10 Off command. At a 0% dimming level, a light is effectively turned off although a small amount of electricity is flowing. The light can then be gradually brought back to a particular level of dimming.
To implement it, I set my remote controls and transceiver module so that they are not on the same house code as my lamp modules. Instead, the signals are captured by the X-10 service which translates them into new X-10 commands with the actual addresses of the lamp modules. In addition, the On and Off commands are translated into corresponding Dim and Bright commands. The system also keeps track of the last known dimming level for each device. I modified my database of X-10 devices to support the concept of a virtual device. That way I can set up a new mapping from a remote control to an appliance module without having to change any code. The system works well but has the disadvantage of a slower response time than that of sending signals directly to devices.
Poor Man's Current Device Status
If you had fancy two-way X-10 devices you could set up automation to poll the devices as needed to get their status; of course, I only have cheap one-way devices. I set up a database with information on my devices including house code and device code and a field for current status. In my simplified view of the world devices are either on or off. When the X-10 service starts up it reads the list of known modules from the database. It then monitors the cm11a interface and listens for any incoming X-10 commands. Any time there is a command sent to a known device, the service updates the record in the database with the last command sent: either On or Off. For an electric baseboard thermostat such as the OTE-X10 this indicates whether or not setback mode is on.
X-10 commands can originate from hand-held remote controls or from the cm17a interface on the other com port. Web pages and scheduled jobs send their X-10 commands via the cm17a and get shadowed in the database. Of course, if an X-10 device state is changed locally by pushing a button on the device itself, there is no way for the X-10 service to know and the database record for the device will be out of sync until the next time an X-10 command is sent to the device.
Potential Future Enhancements
Bruce’s Web Maelström
Copyright © 2001 Bruce