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 startupProcesses.py:

import os
import subprocess

output = os.popen("pgrep mochad").read()
if len(output) > 0:
        print "already running"
else:
        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:

python startupProcesses.py

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.

Advertisements

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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: