Automation: controlling appliances and lights

As I mentioned in the first post, I am using the CM19A to control some of my X10 Transceiver Modules. This could not be any simpler so let me describe how I do it:

Before you plug in the CM19A, simply install mochad. bbx10node has a great blog on how to get it setup. One thing they don’t mention, is that after you build mochad you need to start it up from the main directory (or add it to the environment path). To do this automatically I wrote a simple python program

import os
import subprocess

output = os.popen("pgrep mochad").read()
if len(output) > 0:
        print "already running"
        os.system("sudo /YOURPATHTOMOCHAD/mochad -d &")

This checks if mochad is running, and if it isn’t, it will start it up. Then add the following to your .bash_profile in your home directory:


Now mochad will startup automatically and you never have to worry about it. Now to turn off lights in your python program you simply use this:

import os
os.system("echo 'rf a1 off' | nc localhost 1099")

So easy! And works great, with lights or appliances.

One comment

  1. Harvey A Lewis · · Reply

    I had spent the previous two days trying to control x10 lights from a program without any luck. Many thanks

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: