Christmas with Cron
From StahnkageWiki
I have had a goal since at least 2004 to have my Christmas Tree in cron. Cron is of course the scheduling system of any Unix/Linux system. So, I wanted to control my Christmas Tree with my computers. Now, I have. Controlling a Christmas Tree in cron, at least thus far for me, only involves the lights. I don't automatically hang decorations and disperse presents, maybe that's Version 2.
So, to make my tree work in cron, I needed a few specialty items. They are specialty because not everyone has them. They are normally readily available. To make this work, one requires a method to deliver signals to the electric circuits in the home. There are two big methods of doing this.
I had X10 stuff laying around the house, so I obviously chose that. My costs were minimal. The firecracker or CM17A can be had on ebay for around 14$ shipped. This is a little serial connection device that blasts X10 signals via RF.
So, problem one arises when you have no computers that have serial ports. Serial ports have kind of gone away in the last 4-5 years with USB taking over. So, then I needed a serial to USB converter. This ran me about 9$, and shipping was probably cheap. I got in an order of lots of other good stuff at Newegg. Next, you need some kind of transceiver. So for about $12 shipped you can get one from ebay. I just picked up a one-way transceiver, as this isn't a complex project.
So, next is layer-1, physical connections. First, plugin the Transceiver to the Christmas Tree lights. I set the House Code on the Unit to A, because I am really original.
Next, I plugged in the firecracker to the USB adapter and plugged that into my MythTV (running Fedora) which sits somewhat near the Christmas tree. (Same floor, a couple rooms away).
I plugged it in and checked dmesg, success. I have a device installed. (Who says hardware in linux doens't 'just work'?) Take note of the device it is actually using. In this case it is ttyUSB0.
usbcore: registered new interface driver ftdi_sio drivers/usb/serial/ftdi_sio.c: v1.4.3:USB FTDI Serial Converters Driver usb 1-3: USB disconnect, address 2 ftdi_sio 1-3:1.0: device disconnected ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0 usb 1-2: new full speed USB device using ohci_hcd and address 3 usb 1-2: configuration #1 chosen from 1 choice ftdi_sio 1-2:1.0: FTDI USB Serial Device converter detected drivers/usb/serial/ftdi_sio.c: Detected FT232BM usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0
Ok, now I need some software to control my X10 firecracker. I am sure there lots of software packages out there to do this. I found a very simple one that is all of 397K when downloaded. The program is called heyu and is available from http://www.heyu.org. As a bit of trivia, the name of the program was chosen because the guy writing it was always telling his kids, "Hey you, turn out that light." So, now his computer does it for him.
So, now download the current release of heyu. Then unpack, and compile.
./Configure make sudo make install
Be sure to note what your device name was earlier via dmesg, you will need it during the install.
After that, you run some simple commands to control your transceiver.
To turn on the Christmas Tree
/usr/local/bin/heyu fon A1
To turn off the Christmas Tree
/usr/local/bin/heyu foff A1
Works like champ.
Now, for Cron.
SHELL=/bin/bash # Christmas Tree comes on at 6:10 AM # A1 is the X10 address for my Tree 10 6 * * * /usr/local/bin/heyu fon A1 # Christmas Tree goes off at 7:45 AM 45 7 * * * /usr/local/bin/heyu foff A1 # Christmas Tree comes on at 6:00 PM 0 18 * * * /usr/local/bin/heyu fon A1 # Christmas Tree goes off at 10:30 PM 30 22 * * * /usr/local/bin/heyu foff A1
Well, that my story of getting my Christmas tree working in cron. It took about 25-30 minutes to test and play with things to set it all up. Most of that was testing what outlets I could use for the transceiver and still get the signal across.
| Item | Cost |
|---|---|
| X10 Transceiver | 12$ |
| X10 Firecracker (CM17A) | 14$ |
| Serial to USB converter (optional) | 10$ |
| Heyu Software | 0$ (Open Source) |
| Total | ~36$
|
