Getting your X10 CM17A Firecracker Module Working in Linux

Haven’t you always wanted to control your Christmas lights with your Linux server? Being able to control X10-enabled devices opens up your world to a whole new level of geekness. There are several other powerful reasons to put your computer in control of your lights and appliances including programming simple timers and controlling your lights from anywhere in the world. I’m going to show you how to do it with the CM17A interface. There are plenty others out there like the CM10A, CM11A, and others. You may be able to tweak this article to your needs if you have a different interface other than the CM17A.

Checking your Inventory

Before we can go on, here are the supplies you will need to get the ball rolling.

  1. CM17a Firecracker Module.
    These can be bought from x10.com or eBay.
  2. X10 Transceiver (TM751 or RR501)
  3. Lamp Module (LM465) or Appliance Module (AM466)
    Note: The X10 Transceiver also functions as an appliance module.
  4. Palm Pad Remote (HR12a)
    The remote is optional since we will be using our computer to send commands.

If you need to purchase all items in the list above: consider purchasing a bundle kit, like the CK18A 4 Piece Home Kit.

The items listed above are the minimum to get your X10 home automation started. If you are looking for more geeky automation toys, go to x10.com. Be careful though, it’s easy to spend money on cool stuff like this.

Installing the Software

I use Heyu to control my devices. It’s a simple command-line tool that you can easily integrate into a front-end, or use it as-is out of the box. Combining the command line tool with cron jobs is enough to make it worth it.

Download a copy of the software at Heyu’s Download Page. This is software that you will have to download and compile yourself. If you are used to deb packages and RPM’s, don’t worry. It’s not bad. Download the software and extract it. Fire up a terminal window and cd to that directory. Follow the Quickstart instructions in the INSTALL text file.

Testing the Interface

Now is the time to connect the hardware. Connect the firecracker interface to your primary serial port and connect your other modules. Make note of the house code that you set and the unit code. The house code is the code that all of your devices will adhere to. For example, if your transceiver is on house code D, then all of your devices have to have house code D. I recommend not using A because the Smith’s next door might be too lazy to switch it off of the default as well. The unit code is the unit’s unique ID. Make note of what you set on that as well.

For the purpose of this tutorial, I will be using house code A. Please change accordingly as you read through this.

Once you have everything ready to go, fire up a terminal on your computer with the interface, and type in the following:

heyu fon A1

Then type:

heyu foff A1

If you did everything correctly, you should have heard your transceiver switch on and off. (assuming your transceiver was off to begin with)

Understanding the Command

The two commands above are simple commands using the heyu program. View the man page of the ‘heyu’ command to see all others.

For example, if I wanted to turn off the appliance that has the unit code ’6′ and is on house code ‘A’, I would type this:

heyu foff A6

If I wanted to dim a lamp that was already on that has the unit code ’7′ and house code ‘A’, I would type this:

heyu fdim A7

Simple, no?

Extend the Knowledge

Now that you know how the program works, it’s time to put it to use. Since, these methods of implementation are beyond the scope of this article, I will only be providing the ideas, not a step-by-step. If you need help on the implementation of some of these ideas, please post a question in the comments area, and I will expand on it in another post.

Cron Jobs: Use simple cron jobs to time lights or appliances in your house such as lamps, Christmas lights, etc.

Web Interface: Forgot to turn on your porch light? Now you can from work, your Internet-enabled PDA, wherever! If your server has web server capabilities, make a PHP/HTML front-end to your home’s devices. Here is an example of how you can do it in PHP: X10 PHP Example

Have others? Post it in the comments section below.

This entry was posted on Monday, November 5th, 2007 at 12:52 pm and is filed under Linux. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

11 Responses to “Getting your X10 CM17A Firecracker Module Working in Linux”

Getting your X10 CM19A Module Working in Linux | Pr0gr4mm3r December 27th, 2007 at 12:34 pm

[...] short time ago, I wrote on how to get your X10 CM17A Firecracker module working in Linux. Since then, I have migrated to a new home server, and I am left with no [...]

laroseengineer March 3rd, 2008 at 9:55 pm

I had the sample X10 php working (nice job by the way) and then I tried to use domus.link and I can no longer use the php web page to execute the commands. I can execute the heyu command from the command line but it won’t work through the web any more. Any ideas? I checked the web page and it is owned by root so it should work. No php configuration changes were made. The only thing that is different is I tried out domus.link. There is a X10state file in the /etc/heyu directory that I don’t believe was there before.

Andrew Wells March 3rd, 2008 at 10:05 pm

I haven’t heard about domus.link – I will have to check that out.

At the top of the PHP file, where the $command variable is, try echoing that command, and then manually copy it to a terminal. If the command runs, then you know it’s a PHP problem. If the command fails, then the script isn’t formatting the command correctly. The code may have to be altered accordingly.

Also, I never had to run the page as root, so that might be your problem. It should work at the normal user level.

Let me know if you get anywhere, and thanks for commenting :) .

imali March 21st, 2008 at 9:58 am

Hi Andrew, I’m trying to get an x10 web interface working using tht PHP example. I’m using a CM12u module through USB interface with Heyu. I can execute heyu commands direct from the command line but nothing happens when I try through the web interface. I’ve modified your php file only slightly by changing ‘fon’ and ‘foff’ commands to ‘on’ and ‘off’ but other than this everything is the same. Any suggestions? By the way I’m quite new to linux and php too.

Oh yes, I tried another thing also…at the top of the php file in the ‘if’ brackets i tried putting an echo “$output”; and this returned “unable to find Heyu configuration file’ in the webpage. I’ve not changed the default location of the x10config that comes with heyu….it’s in home/user/.heyu/x10config.

Andrew Wells March 21st, 2008 at 10:11 am

Hi imali, I’m pretty sure your problem is that Apache & PHP is running as a different user than what you normally run the command under, so it’s not finding the config file in your home directory.

Try adding the full path to the config file in the Heyu command. You can do that by passing the -c switch. Put this option before the rest of the command, so it will look like this:

heyu -c /home/user/.heyu/x10config [rest of command]

If you still run into problems, output the $command variable as well. Copy that into a terminal and see if it works there.

Let me know if that helps.

imali March 21st, 2008 at 2:15 pm

Right, I’m getting a bit further now. Added the full path as suggested and still nothing. So I echo $command and I get “heyu -c /home/user/.heyu/x10config on A2 2>&1″ If I copy/paste this into the terminal it works fine. but nothing through the web interface.

echoing $output now gives “Unable to write in Heyu directory ‘/home/user/.heyu/’ HEYU: Can’t open tty line. Check the permissions.” so you’re right it looks like a permissions problem.

I’ve changed the ownership of the x10config file from user to root, and the same for the index.php as well. this hasn’t helped.

Any further help would be appreciated :)

Andrew Wells March 21st, 2008 at 2:28 pm

Changing the ownership of the index.php file won’t change the run-time user of the script unless you have suphp or suexec installed. On most systems, web scripts are run as www-data. You can verify that by running the following code in a php script:

< ?php echo shell_exec("whoami"); ?>
You may have to change the quotes back to the non-fancy ones as WordPress likes to mess with them.

I would recommend reinstalling heyu and specify the option for a global config file so it can be accessed under multiple users, or create another config file under the same user as your web interface.

Keep me updated :)

imali March 31st, 2008 at 2:48 pm

Just an update on this….I managed to get the PHP example working. It was indeed user and groups issue. I didn’t do the full HEYU reinstall but added the user www-data to the tty group under linux and that seems to have resolved the issue.

Andrew Wells April 1st, 2008 at 1:29 pm

Glad to see you were able to get it working. I will update this post to recommend a system-wide configuration file to avoid problems such as this.

U-notez » Automate Your Christmas Lights! - Unitz LLC December 17th, 2009 at 9:34 am

[...] This same approach can be used with other operating systems. In Linux it can be done with bash scripts and cron jobs – the following explains how to control the CM17a in Linux. [...]

Marc Perkel July 28th, 2011 at 4:08 pm

I had to send a heyu freset command (USB Port) before it worked.

Leave a Reply