X10 Community Forum

General Category => Mac/Linux & Open Source and the X10 Home => Topic started by: mmauka on December 10, 2010, 12:55:50 AM

Title: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 10, 2010, 12:55:50 AM
mochad is a Linux TCP gateway daemon for the X10 CM15A RF (radio frequency) and PL (power line) controller and the CM19A RF controller.

mochad stands for Multiple Online Controllers for Home Automation Daemon. Pronouce like mocha-d, not mo-chad.

mochad is now on sourceforge.net.

    http://sourceforge.net/projects/mochad

Many things are To Be Done but it works on Ubuntu 10.04 and 10.10 and three OpenWrt devices: LinkSys NSLU2 (very old), Seagate DockStar, and Buffalo WZR-HP-G300NH WiFi router. However, details on building for OpenWrt are not in the README yet. TBD is creating a package for easier building and installation.

See the README for more details on which X10 modules are known to work with mochad.

mochad is not a full home automation program. It is a device driver with TCP socket interface. mochad is implemented using libusb-1.0 so is not a Linux kernel device driver.

Post questions or comments here or on the sourceforge discussion page.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: pconroy on December 10, 2010, 09:56:26 PM
I'm lost.

Does mochad control the CM15A and CM19A?
thx
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 10, 2010, 10:38:35 PM
I'm lost.

Does mochad control the CM15A and CM19A?
thx

Sorry, yes. mochad runs in the background and controls the CM15A and CM19A. mochad accepts TCP connections on port 1099 so client programs such as netcat can send RF/PL commands to mochad and receive RF/PL events from mochad.

I expanded the README into a Wikipage <http://sourceforge.net/apps/mediawiki/mochad/index.php?title=Main_Page>. This is clearer than my late night posting.

I forgot to add mochad supports RF camera events/commands as well.

RFCAM <camera command>

where <camera command> is one of the following:

CAMUP CAMDOWN CAMLEFT CAMRIGHT CAMCENTER CAMSWEEP CAMPRESET1 CAMPRESET2
CAMPRESET3 CAMPRESET4 CAMPRESET5 CAMPRESET6 CAMPRESET7 CAMPRESET8 CAMPRESET9
CAMEDITPRESET1 CAMEDITPRESET2 CAMEDITPRESET3 CAMEDITPRESET4 CAMEDITPRESET5
CAMEDITPRESET6 CAMEDITPRESET7 CAMEDITPRESET8 CAMEDITPRESET9

I do not own any X10 cameras so this is based on examining USB packets generated by AHP when clicking buttons in the virtual remote control pad for the VK7X module. I am interested in hearing if this actually works.

Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: pconroy on December 11, 2010, 08:05:43 PM
Way cool!

Did you reverse engineer the CM15A protocol????

Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 11, 2010, 09:25:20 PM
I did reverse engineer but with a lot of help from existing X10 protocol documentation listed in the README file and from USB Snoopy. USB Snoopy is an open source Windows USB sniffer.

Macros and timers are too complex so they are not supported. Looks like there are some similarities to the CM11A but there are too many differences for me to figure out.

The standard X10 PL, X10 RF, and X10 RF security packets should all work. The X10 camera commands are incomplete.

To Do list

Hotplug support so mochad runs when a CM15A/CM19A is plugged in. Currently, the controller must be plugged in when the mochad starts. If not, mochad bails out with a warning message in /var/log/messages.

Use GNU autotools/automake because most packaging tools require them.

Create Ubuntu and OpenWrt packages for easier installation.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: Brandt on December 11, 2010, 10:13:25 PM
what does TCP have to do with anything?
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 12, 2010, 12:45:43 AM
TCP is the way applications communicate with mochad and the CM15A/CM19A. I have not used heyu or misterhouse but I was thinking they might be able to use mochad as a backend device driver by opening a TCP socket to it.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: Brandt on December 12, 2010, 02:10:27 AM
well you could join the heyu_users email list and post about it and see what people have to say
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 12, 2010, 03:46:23 PM
mochad is still a work in progress and I am writing my own HA app using mochad with more than one controller. Using more than one controller is the original, and still the primary, reason for the network interface. If I had more time I would get involved in other projects but it is not possible right now.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: coolguy1233457 on December 20, 2010, 01:03:58 PM
Hi there !!

First, thank you so much for your work, very appreciated...

I was using heyu for it's CM17A (firecracker) support to send commands to my CM15A.

Now, with mochad, I can get rid of the CM17A and have a look at the CM15A transmitted and received x10
commands.

But ...

I have a question, the dim and bright commands (of a normal lamp module) do not behave like with
heyu.  Can you give an explanation of what is the number 0..31 that we give ?  With heyu, that was the number
of dim or bright steps (steps of 6% with a CM15A) sent to the device. 

Also, an interesting feature to add would be adding a feature that would watch for certain command or
logs to launch a user defined script.  I think I'll do that my way, but when the daemon starts, it
would be interesting to have a log file (and not having to log with netstat).

Will you develop mochad actively ??? what's on your todo list ?

Thanks again
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 20, 2010, 05:58:33 PM
I'm glad to hear it is working for you.

There are two dim commands.

pl a1 dim 0..31     sends the dim command for older lamp modules

This only works with older lamp modules. I am fairly new to X10 so my gear has
been purchased in the last couple of years so none of my lamp modules
understand this command.

As far as I can tell, 0..31 is the number of steps to dim or brighten. The way
to make it go to 50% dim is to first turn the lamp on to full brightness then
send a dim 15. But this is just a guess because I have no way to test this.

pl a1 xdim 0..63    sends the extended pre-set dim

If you have newer lamp modules (LM465) with soft-start, the xdim command is
required. 0..63 is the absolute intensity level so for 50% send 32, 75% send
48, etc. 63 is a special value that means go to maximum intensity instantly.
62 is the maximum intensity with soft-start.

The value can range from 0..255 according to the X10 specification but the
LM465 ignores the higher values. The upper two bits are supposed to control the
rate at which the intensity changes (faster or slower) but the LM465 is not
affected.

I like the idea of mochad write a log file. I usually do something like this
"nc localhost 1099 >logfile.txt &" but it is one extra step.

At least for the moment, mochad is more like an SDK than a full HA application
like heyu or misterhouse. It is fairly easy to use Perl as a scripting language
to implement your own HA app. Any language that can connect to a TCP socket can
be used.

For example, bash has a socket programming API so shell programmers can connect
to mochad directly. It is "merely" a matter of examining ASCII text strings for
the desired events. This is simple enough for a single device but will get
complex if you have a house full of various kinds of modules. But the minimum
amount of code to create a useful HA app is quite small. BTW, flite is a small
text-to-speech command line program.

#!/bin/bash
#This bash program connects to mochad then scans for alert/normal events from
#a specific DS10A. The lamp or appliance module M1 is turned on
#for alerts and off for normal. Assuming flite is installed, voice prompts
#should also be heard.
#Sample event generated by mochad for a DS10A
#12/20 11:53:58 Rx RFSEC Addr: EF:43:80 Func: Contact_alert_min_low_DS10A

# Connect TCP socket to 192.168.1.254 port 1099 on handle 6.
exec 6<>/dev/tcp/192.168.1.254/1099

# RF devices send the same event multiple times so to avoid multiple
# PL commands and voice prompts, keep track of the device state.
ds10state="unknown"

while read <&6
do
    # Show the line on standard output just for debugging.
    echo $REPLY >&1
    case $REPLY in
        *Rx\ RFSEC\ Addr:\ EF:43:80*alert*)
        if [ "$ds10state" != "alert" ]
        then
                echo "pl m1 on" >&6
                flite -t "Door open"
                ds10state="alert"
        fi
        ;;
        *Rx\ RFSEC\ Addr:\ EF:43:80*normal*)
            if [ "$ds10state" != "normal" ]
            then
                echo "pl m1 off" >&6
                flite -t "Door closed"
                ds10state="normal"
            fi
        ;;
    esac
done

Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: coolguy1233457 on December 21, 2010, 09:33:43 AM
hello,

Have you really tested the dim and xdim with a lamp module ?
I have LM465 modules, and I've bought very recently, probably they're the newer model.

xdim doesn't work at all, does nothing (I could post the nc output, if you want).
dim doesn't work at all like you say... i really don't understand how it works...
it doesn't seem to be at % of the max intensity

with heyu, the dim command was really a small step in increasing or decreasing the
intensity of about 6%, and it worked fine.   I am not sure there was a way
to tell the module to directly go to 50% or 75% of the max intensity.
In fact, if possible, both ways of controlling the intensity are
interesting... depending on the application !

are you able to test it out ?

the on and off commands are working fine thought...

yes, redirecting the nc output was what I was doing (a line I added to rc.local or rc.start)
but why not use a init script with the syslog facility ?
and I was thinking of something like your bash script to keep an eye on events
and exec some scripts... 

give me news as soon as you "put some light" on the dim/bright commands ;-)
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: Brian H on December 21, 2010, 09:40:46 AM
Unless X10 has changed things again.
All my recent LM465s with soft start will not dim to 0%. The lowest I have gotten is about an estimated 20%.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: coolguy1233457 on December 21, 2010, 11:52:20 AM
well maybe, but whatever the number I put in the command
pl a1 dim 0..31
it gets to minimum intensity (almost off).

Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: Brian H on December 21, 2010, 12:38:35 PM
Could be. I only used the standard dim and not extended dim commands in my tests.
Are they soft start?
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: coolguy1233457 on December 21, 2010, 12:41:27 PM
this is standard dim.
not xdim.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: Brian H on December 21, 2010, 12:50:15 PM
Do you have the date code handy?
Are they Soft Start?
X10 could have changed things again. I have found two different soft start modules acting completely different. Depending on age.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: coolguy1233457 on December 21, 2010, 12:53:12 PM
I am really not sure the problem comes from there...
They were working as expected with heyu.

Don't know where to find the code you're talking about...
I just bought them, so they're recent.

Do you know what is the command heyu send to dim or bright BY a % level
instead of making them get TO a % level ?
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: Brian H on December 21, 2010, 01:08:05 PM
The date code is on a small round white sticker on the back.
If they are new then they should be soft start. Where they ramp on and off in about two to three seconds.

I am a Windows guy and was testing dimming and brightening with AHP, Smarthome Manager Essentials; a HR12 Palmpad Remote with transceiver and a TR16A local buttons.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 21, 2010, 02:40:22 PM
Have you really tested the dim and xdim with a lamp module ?
I have LM465 modules, and I've bought very recently, probably they're the newer model.


Posting a log file would be useful. I am not sure how heyu works because I do not have any serial port controllers  (CM11A, etc.).

I have tested xdim with several LM465, all with soft-start and they all work with xdim. I do not have any non-soft-start lamp modules.

In this test, B3 is an LM465 with soft-start. When turned on using "pl b3 on" it takes 2-3 seconds to go from off to full intensity. This means the LM465 has soft-start so the xdim command is required.


$ nc localhost 1099
pl b3 on
12/21 09:20:06 Tx PL HouseUnit: B3
12/21 09:20:06 Tx PL House: B Func: On
pl b3 xdim 32       # 50% intensity
12/21 09:20:28 Tx PL HouseUnit: B3
12/21 09:20:28 Tx PL House: B Func: Ext code 1, data, control Data: 20 Command: 31
pl b3 xdim 63       # 100% intensity
12/21 09:20:36 Tx PL HouseUnit: B3
12/21 09:20:36 Tx PL House: B Func: Ext code 1, data, control Data: 3F Command: 31
pl b3 xdim 0        # 0% intensity
12/21 09:20:42 Tx PL HouseUnit: B3
12/21 09:20:42 Tx PL House: B Func: Ext code 1, data, control Data: 00 Command: 31
pl b3 off           # off
12/21 09:20:55 Tx PL HouseUnit: B3
12/21 09:20:55 Tx PL House: B Func: Off
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 21, 2010, 02:42:50 PM
well maybe, but whatever the number I put in the command
pl a1 dim 0..31
it gets to minimum intensity (almost off).



If the lamp module has soft-start the dim command does NOT work. Use xdim like this

pl a1 xdim 32
pl a1 xdim 63
pl a1 xdim 0
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: coolguy1233457 on December 21, 2010, 02:44:18 PM
ok, will try this at home in a few hours... and will post the logs
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 21, 2010, 02:46:56 PM
All my recent LM465s with soft start will not dim to 0%. The lowest I have gotten is about an estimated 20%.

My LM465 go dark with "pl a1 xdim 0" though I usually send an off command to make sure. It is certainly possible the LM465 firmware has changed so I am not saying you are wrong. The date code on my units are 08I37.

Sorry, I just realized dim and not xdim was being discussed. I also see using regular dim never reduces the intensity to completely off. I gave up using dim/bright with soft-start LM465.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: coolguy1233457 on December 21, 2010, 05:46:06 PM
here we go: 
Code: [Select]
n@my_gentoo - >   nc localhost 1099
pl a2 on
12/21 17:44:02 Tx PL HouseUnit: A2
12/21 17:44:02 Tx PL House: A Func: On
pl a2 xdim 32
12/21 17:44:07 Tx PL HouseUnit: A2
12/21 17:44:07 Tx PL House: A Func: Ext code 1, data, control Data: 20 Command: 31
pl a2 xdim 63
12/21 17:44:22 Tx PL HouseUnit: A2
12/21 17:44:22 Tx PL House: A Func: Ext code 1, data, control Data: 3F Command: 31
pl a2 xdim 0
12/21 17:44:34 Tx PL HouseUnit: A2
12/21 17:44:34 Tx PL House: A Func: Ext code 1, data, control Data: 00 Command: 31
pl a2 off
12/21 17:44:45 Tx PL HouseUnit: A2
12/21 17:44:45 Tx PL House: A Func: Off

nothing happens with the xdim commands
on and off goes well

and for the sticker, it says : 10A02


Code: [Select]
pl a2 dim 5
12/21 17:52:57 Tx PL HouseUnit: A2
12/21 17:52:57 Tx PL House: A Func: Dim(5)
pl a2 off
12/21 17:53:10 Tx PL HouseUnit: A2
12/21 17:53:10 Tx PL House: A Func: Off
pl a2 on
12/21 17:53:15 Tx PL HouseUnit: A2
12/21 17:53:15 Tx PL House: A Func: On
pl a2 dim 30
12/21 17:53:23 Tx PL HouseUnit: A2
12/21 17:53:23 Tx PL House: A Func: Dim(30)

those 2 different dim commands produce the same result, same intensity (almost off)

okay, and finally, let me recall (again, I know) that using heyu with a CM17A (firecracker)
to send commands to the same CM15A controller, everything was working fine.

heyu fdim 5 (was decreasing of 6% the intensity)
heyu fdim 10 (was decreasing of 6% the intensity)
heyu fbright 10 (was increasing of 12% the intensity, and if it was off, it worked anyways)
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 21, 2010, 06:54:33 PM
Well, I am stumped. xdim works fine on my LM465s. The dim/bright commands never work correctly.

I suggest wiping the CM15A memory using Windows AHP. Stored macros and timers may interfere with the mochad. Also the CM15A has a built-in RF to PL repeater which should be disabled to avoid duplicate transmissions.

The two options are:

Tools | Clear Interface Memory

This can take a few minutes to complete.

Tools | Hardware Interface Configuration.

Check the None box for "Transceived House Code(s)".
Click "Update Interface".

See if this helps with xdim.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: Brian H on December 21, 2010, 07:00:35 PM
10A02 is a week two of 2010. So it is a new one as you indicated.

Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: coolguy1233457 on December 21, 2010, 07:16:22 PM
hello,

nope, nothing changed after clearing the memory and disabling repeating...
still no effect after a xdim (in despite of the message)

also something strange i noticed :

 root@my_gentoo - >   x10cmd pl a2 bright 27
12/21 19:10:23 Tx PL HouseUnit: A2
12/21 19:10:23 Tx PL House: A Func: Bright(27)
#607 Tue Dec 21 19:10:23 /usr/src/linux
 root@my_gentoo - >   x10cmd pl a2 bright 2
12/21 19:10:28 Tx PL HouseUnit: A2
12/21 19:10:28 Tx PL House: A Func: Bright(2)


the second command makes the light even brighter... !!

and any dim command (e.g. pl a2 dim 29 or pl a2 dim 2)
will produce the same intensity (the minimum (but device is still on)) !!

Very strange indeed ??
any idea in whats the difference with heyu that is able to increase/decrease
by a % ?
do you support those commands ?

I am wondering in your case what is the difference between:
pl a2 xdim 32
and
pl a2 xbright 32

Thanks again for your support !!
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 21, 2010, 09:24:05 PM
Please try 0.1.3 which sends dim/bright commands in a different way, matching what a recent AHP 2.9? does. This seems to work better than the old way. Even when using the brightness slider in AHP, the LM465 sometimes goes to mininum brightness when it should not.

However, it appears your LM465 does not understand extended pre-set dim so dim/bright are your only choice. Of course, this could be another bug in mochad so it would be interesting to hear sucess or failure from other users and their date codes.

http://sourceforge.net/projects/mochad/files/mochad-0.1.3.tar.gz

dim/bright specify relative changes to intensity. bright 27 increases intensity 27 steps. bright 2 increases intensity 2 more steps. dim 10 decreases intensity 10 steps.

Also note there are 5 bits for dim/bright so the range of values is 0..31 but elsewhere in the X10 protocol docs, 0..22 is mentioned as the range of dim/bright values. So this suggests "pl a1 on" followed by "pl a1 dim 11" should produce 50% intensity. "pl a1 dim 6" should produce 25%. "pl a1 bright 17" should produce 100%.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 21, 2010, 09:31:52 PM
Very strange indeed ??
any idea in whats the difference with heyu that is able to increase/decrease
by a % ?
do you support those commands ?

No support for % changes. mochad is a device driver so it expects low level values.

I am wondering in your case what is the difference between:
pl a2 xdim 32
and
pl a2 xbright 32

There is no xbright command because xdim changes the intensity up or down. Whereas, dim always decreases intensity and bright increases.


Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: coolguy1233457 on December 22, 2010, 07:41:59 AM
wow  !!! impressive ! you rule !

now everything works as with heyu, I don't know what you changed exactly but
my modules liked it ! 

Code: [Select]
root@my_gentoo - >   nc localhost 1099
pl a2 off
12/22 07:38:53 Tx PL HouseUnit: A2
12/22 07:38:53 Tx PL House: A Func: Off
pl a2 bright 5
12/22 07:39:01 Tx PL HouseUnit: A2
12/22 07:39:01 Tx PL House: A Func: Bright(5)
pl a2 dim 5
12/22 07:39:10 Tx PL HouseUnit: A2
12/22 07:39:10 Tx PL House: A Func: Dim(5)
pl a2 off
12/22 07:39:19 Tx PL HouseUnit: A2
12/22 07:39:19 Tx PL House: A Func: Off

and, it never completely goes off with a dim command,
it has to receive an off command

thank you,

ever played with eagle eye MR14A ?
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on December 22, 2010, 04:55:26 PM
Whew! I am glad to hear dim/bright is working.

Non-security/regular wireless motion sensors send "rf a1 on" and "rf a1 off" so they are pretty simple. I use the RF security MS10A which send out different messages. In either case, writing a program to connect to port 1099 then scan for specific events is the basis for creating an app. The apps/ directory in the 0.1.3 tarball has examples in shell and Perl.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: coolguy1233457 on December 23, 2010, 09:07:00 AM
yes I know it's pretty simple ... what would be best is having a real log file
that use syslog (I use syslog-ng) and logrotate.  I already managed redirecting
the nc output manually in rc.local but that would be better if you
officially integrate a logfile in a future release. 

What are the scripts you developped ? Anything with the door sensors ?
If you want to share, I'd be interested... but anyways, I'll make my own.

Thank you again !
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: fastplymouth on December 31, 2010, 11:42:17 AM

I forgot to add mochad supports RF camera events/commands as well.

RFCAM <camera command>

where <camera command> is one of the following:

CAMUP CAMDOWN CAMLEFT CAMRIGHT CAMCENTER CAMSWEEP CAMPRESET1 CAMPRESET2
CAMPRESET3 CAMPRESET4 CAMPRESET5 CAMPRESET6 CAMPRESET7 CAMPRESET8 CAMPRESET9
CAMEDITPRESET1 CAMEDITPRESET2 CAMEDITPRESET3 CAMEDITPRESET4 CAMEDITPRESET5
CAMEDITPRESET6 CAMEDITPRESET7 CAMEDITPRESET8 CAMEDITPRESET9

I do not own any X10 cameras so this is based on examining USB packets generated by AHP when clicking buttons in the virtual remote control pad for the VK7X module. I am interested in hearing if this actually works.


Hi!

I'm using your driver and it works great, however I have a need to send camera commands to ninja x10 bases as well. I'd like to test the syntax above but how do you address specific ninja bases if you have more than 1 (they have addressable power supplies)? I'll let you know how the testing goes!

Thanks #:)
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: pconroy on January 18, 2011, 07:16:19 PM
Whew! I am glad to hear dim/bright is working.

Non-security/regular wireless motion sensors send "rf a1 on" and "rf a1 off" so they are pretty simple. I use the RF security MS10A which send out different messages. In either case, writing a program to connect to port 1099 then scan for specific events is the basis for creating an app. The apps/ directory in the 0.1.3 tarball has examples in shell and Perl.


I'm late but I too finally downloaded and installed the code.
Works fine.

I had to blacklist a couple of standard ubuntu modules and I'm not sure you mention that in the docs.
Anyway - thanks for writing this! 

:)
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: Cairan on February 21, 2011, 10:44:59 PM
Anyone working on compiling a package for brcm-2.4 Kamikaze 8.09.2... I've been trying to coax it to work and alas it doesn't quite work out...
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on February 22, 2011, 06:02:49 AM
I had to blacklist a couple of standard ubuntu modules and I'm not sure you mention that in the docs.

Thanks, I was not aware the need for blacklisting. Perhaps it has to do with
the other USB devices in the system and/or the Linux version. Or maybe it has
to do with Ubuntu 10.04 using udev.

If /etc/udev exists, "make install" should copy
udev/91-usb-x10-controllers.rules to /etc/udev/rules.d. This udev rule runs
mochad whenever a cm15a or cm19a is plugged in to the system and on boot.

If the Linux distro does not use udev, "make install" will not touch anything
in /etc so manual editing will be required.

Anyone working on compiling a package for brcm-2.4 Kamikaze 8.09.2... I've been trying to coax it to work and alas it doesn't quite work out...

The following page describes how to get the mochad package Makefile into the
OpenWrt package building system. But I do not know if this works for kamikaze 8.09.2
but it might contain useful information on how to make it work.

http://sourceforge.net/apps/mediawiki/mochad/index.php?title=OpenWrt

Would upgrading to backfire be possible?

mochad/backfire 10.03 on a Buffalo WiFi router and mochad/trunk on a Seagate Dockstar
are known to build and work correctly.

mmauka
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: fastplymouth on February 26, 2011, 02:49:11 PM
Hi mmauka,


I thought I'd report back on my findings after playing with the ninja pan/tilt mounts and mochad.

Based on observations of the decoded signals from the CR14A camera remote, and Dave Houston's breakdown of the x10 camera protocol (http://davehouston.net/cr14a-rf.htm) it would seem that mochad only supports encoding/decoding of commands for housecode N. Switching the CR14A remote to any other housecode and triggering commands results in "Unknown RF camera command" errors.

I'm a .net programmer so C is not my strong suit, but I thought I'd take a whack at adding support for a housecode parameter in the RFCAM command set. Shall I email you a patch or post it here?

Thanks again for a great driver!


Ken
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on February 26, 2011, 04:11:36 PM
Based on observations of the decoded signals from the CR14A camera remote, and Dave Houston's breakdown of the x10 camera protocol (http://davehouston.net/cr14a-rf.htm) it would seem that mochad only supports encoding/decoding of commands for housecode N. Switching the CR14A remote to any other housecode and triggering commands results in "Unknown RF camera command" errors.

I'm a .net programmer so C is not my strong suit, but I thought I'd take a whack at adding support for a housecode parameter in the RFCAM command set. Shall I email you a patch or post it here?


Ken,

Thanks for the rf camera info. I did not know the rf camera protocol supports 16 house codes.

Dave Houston has documented everything required to make this work for all house codes. I'll look at the source today.

Any help would be appreciated. Posting here is fine.

Thanks,
mmauka
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on February 26, 2011, 09:57:41 PM
Ken,

I released mochad 0.1.4 on sourceforge.net. The RFCAM command should work with house codes now. "rfcam D camup" should send a camera pan up command to house D.

Let me know how it works.

http://sourceforge.net/projects/mochad/

mmauka
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on March 03, 2011, 04:57:17 AM
Anyone working on compiling a package for brcm-2.4 Kamikaze 8.09.2... I've been trying to coax it to work and alas it doesn't quite work out...

Other people have inquired so I tried this out. See the page below for details on building mochad for the 8.09 branch.

http://sourceforge.net/apps/mediawiki/mochad/index.php?title=OpenWrt

Warning I do not have hardware to test this so I make no guarantees.

mmauka


Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: fastplymouth on March 05, 2011, 10:45:07 AM

I released mochad 0.1.4 on sourceforge.net. The RFCAM command should work with house codes now. "rfcam D camup" should send a camera pan up command to house D.

Let me know how it works.

http://sourceforge.net/projects/mochad/



Ah, looks like you beat me to it :)

I just tried it out and it works perfectly with all of my ninja mounts. Thanks again!!


-Ken
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on March 09, 2011, 09:57:57 PM
mochad 0.1.6 is now available on SourceForge.

http://sourceforge.net/projects/mochad/files

This version adds an RF event filter to eliminate the flurry of duplicate
RF events when a key is pressed or a sensor is triggered. This makes it
easier to write applications that process mochad events.

In addition, mochad compiled for Chumby is now available.

CHAXI -- Chumby Home Automation X10 Interface
================================

The programs included in the CHAXI toolkit allow you to build Chumby command
line applications that integrate X10 sensors and modules with Chumby.

chaxi.zip   -- CHAXI toolkit zip file with compiled mochad and sample programs.
                Unzip to a Flash drive and plug into Chumby along with a
                CM19A or CM15A.

Contents of chaxi.zip

chaxi.txt   -- Instructions for using CHAXI.

debugchumby -- Auto run file for Chumby.

mochad      -- X10 to TCP gateway for CM19A and CM15A.

alarm.sh    -- Make Chumby react to motion and light using an X10 wireless
                motion and light sensor.

radio.sh    -- Use an X10 wireless remote to control Chumby's radio.

sendsms.template -- Fill in the blanks to send SMS messages to your phone.
                Once this works, you can send SMS messages on motion sensor
                and door/windows sensor alerts.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: hawk1 on April 17, 2011, 11:24:02 AM
Got this working on my Ultimate Edition!  Very cool!  I was wondering if anybody has made a Kommander script for this or actually created a program that uses this? 

If not I was wondering if someone could write a kommander script that  uses combo boxes to select the house and unit code and how I would fire it off once the value in the combo box was selected.  I think I got the combo boxes down. 

Just trying to figure out a exec button to fire it with the values from the combo boxes.   Thanks.  Newbie at Linux but loving it.   ??? 

Disregard question.  Figured it out.  thanks
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: hawk1 on April 20, 2011, 01:24:10 PM
Has anyone made a gui for this yet?
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on April 21, 2011, 03:22:25 AM

No GUI like AHP but here is small Python demo app with buttons for
On,Off,Bright,Dim. Should work on all Python platforms including Windows
and MacOS but only tested on Ubuntu Linux 10.04.

Code: [Select]
# Python demo interface to mochad. Pressing GUI buttons sends commands to
# mochad to turn lights on,off,bright,and dim. There must be a better way
# to avoid such repetive code. Should work on other support Python platforms
# such as Windows and MacOS but only tested on Ubuntu Linux 10.04.
#
from Tkinter import *
import socket

# Change this to localhost if this program runs on the same host as mochad. Or
# change to the correct IP.
MOCHADHOST="192.168.1.254"
MOCHADPORT=1099

def netcat(hostname, port, content):
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((hostname, port))
    s.sendall(content)
    s.close()

def mochad(command):
    netcat(MOCHADHOST, MOCHADPORT, command)

class App:

    def __init__(self, master):

        frame = Frame(master)
        frame.grid()

        Label(frame, text="Bedroom 1").grid(row=0)
        self.bed1_on = Button(frame, text="On", command=self.bed1_on_cb)
        self.bed1_on.grid(row=0,column=1)

        self.bed1_off = Button(frame, text="Off", command=self.bed1_off_cb)
        self.bed1_off.grid(row=0,column=2)

        self.bed1_bright = Button(frame, text="Bright", command=self.bed1_bright_cb)
        self.bed1_bright.grid(row=0,column=3)

        self.bed1_dim = Button(frame, text="Dim", command=self.bed1_dim_cb)
        self.bed1_dim.grid(row=0,column=4)

        Label(frame, text="Bedroom 2").grid(row=1)
        self.bed2_on = Button(frame, text="On", command=self.bed2_on_cb)
        self.bed2_on.grid(row=1,column=1)

        self.bed2_off = Button(frame, text="Off", command=self.bed2_off_cb)
        self.bed2_off.grid(row=1,column=2)

        self.bed2_bright = Button(frame, text="Bright", command=self.bed2_bright_cb)
        self.bed2_bright.grid(row=1,column=3)

        self.bed2_dim = Button(frame, text="Dim", command=self.bed2_dim_cb)
        self.bed2_dim.grid(row=1,column=4)

# Callback functions invoked when buttons pressed.
# Change "pl" to "rf" if using a CM19A.
    def bed1_on_cb(self):
        print "bed 1 on"
        mochad("pl b3 on\n")

    def bed1_off_cb(self):
        print "bed 1 off"
        mochad("pl b3 off\n")

    def bed1_bright_cb(self):
        print "bed 1 bright"
        mochad("pl b3 bright\n")

    def bed1_dim_cb(self):
        print "bed 1 dim"
        mochad("pl b3 dim\n")

    def bed2_on_cb(self):
        print "bed 2 on"
        mochad("pl b4 on\n")

    def bed2_off_cb(self):
        print "bed 2 off"
        mochad("pl b4 off\n")

    def bed2_bright_cb(self):
        print "bed 2 bright"
        mochad("pl b4 bright\n")

    def bed2_dim_cb(self):
        print "bed 2 dim"
        mochad("pl b4 dim\n")

root = Tk()
app = App(root)
root.mainloop()
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on April 21, 2011, 10:02:58 PM
An interesting HA app I have looked at but not used is OpenRemote (OR) at openremote.org. The GUI designer for iPhone/iPad/Android looks good. The CM15A is not supported but TCP devices are supported. It is possible to create an Android or iPhone control panel with buttons that send strings to a TCP socket. In theory, this should work with mochad.

I currently do not have an iPhone or Android device so have not tried OR. I am not sure how timed events work (for example, turn off lights at dawn) or how sensors are handled. The GUI does allow definition of sensors but I am not sure sensors can be linked to specific messages from a mochad TCP socket.

The project supports Win, Mac, Linux, iPhone/iPad, and Android. The documentation needs work.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: bakelite on April 24, 2011, 03:42:47 PM
Hi, fantastic I have been looking for a Linux version for a while. However only the RF commands appear to work the PL commands echo back OK in netcat but don't operate my X10 devices :-( Could this be because I am using a UK CM15Pro ?? I have complied this on Dedian. Many thanks
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on April 24, 2011, 09:35:58 PM
I suggest plugging the controller and a lamp or appliance module into the same
wall outlet or powerstrip then see if mochad can control the module. If not,
make sure the modules are compatible with the controller. If you purchased the
CM15Pro and the modules at the same time from the same vendor, they should work
together. mochad does not contain any options for the CM15Pro so it should
"just work". At least one person reported the CM15Pro works with mochad.
Be sure use the latest mochad version (0.1.7) because perhaps you have run
into an old bug.

Another thing to try is to connect the CM15 controller to a PC running the
provided Windows software and wipe out the controller memory. This removes all
internal macros and timers which can cause problems. I also remove the
batteries since mochad does not use the controller internal date/time clock.
And lastly, disable the internal RF to PL transceiver. These are options
controlled by the Windows AHP software.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: bakelite on April 25, 2011, 08:44:13 AM
Firstly many thanks for your help, and advice.

I have now tried my X10 devices on the same power point (no surge protector). I have cleared the interface, stopped transceiver and removed the battery etc. I am using the latest 0.1.7

So far my X10 devices work OK controlled by AH under windows, however not from Debian. If I use the rf a1 start, or rf a1 stop the command is repeated via my wireless device and the appliances turn on and off OK (see bellow)

rf a1 on
04/25 13:26:31 Tx RF HouseUnit: A1 Func: On
04/25 13:26:31 Tx PL HouseUnit: A1
04/25 13:26:31 Tx PL House: A Func: On
04/25 13:26:36 Rx PL HouseUnit: A1


rf a1 off
04/25 13:28:16 Tx RF HouseUnit: A1 Func: Off
04/25 13:28:16 Tx PL HouseUnit: A1
04/25 13:28:16 Tx PL House: A Func: Off
04/25 13:28:21 Rx PL HouseUnit: A1


{Turns A1 ON/OFF OK}

However when I issue the pl commands the devices do not respond (see below)

pl a1 on
04/25 13:30:28 Tx PL HouseUnit: A1
04/25 13:30:28 Tx PL House: A Func: On

pl a1 off
04/25 13:30:44 Tx PL HouseUnit: A1
04/25 13:30:44 Tx PL House: A Func: Off


{Look OK to me however A1 not turning ON OR OFF}

FYI, everything looks OK in the messages logfile (see below)
Apr 25 12:52:58 test-linux01 kernel: [65251.848059] usb 3-2: new low speed USB device using uhci_hcd and address 8
Apr 25 12:52:58 test-linux01 kernel: [65252.034065] usb 3-2: New USB device found, idVendor=0bc7, idProduct=0001
Apr 25 12:52:58 test-linux01 kernel: [65252.034098] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Apr 25 12:52:58 test-linux01 kernel: [65252.034106] usb 3-2: Product: USB ActiveHome Interface
Apr 25 12:52:58 test-linux01 kernel: [65252.034112] usb 3-2: Manufacturer: X10 Wireless Technology Inc
Apr 25 12:52:58 test-linux01 kernel: [65252.034343] usb 3-2: configuration #1 chosen from 1 choice
Apr 25 12:52:58 test-linux01 mochad[2285]: starting
Apr 25 12:52:58 test-linux01 mochad[2286]: Found CM15A


Anything else I can try ??

P.S Under nc in debian I needed to add the q option to return control in my shell scripts. So rather than use
$ echo "pl a all_lights_off" | nc localhost 1099
I had to use
$ echo "pl a all_lights_off" | nc -q 1 localhost 1099

Thanks again
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: mmauka on April 25, 2011, 08:00:11 PM
rf a1 on
04/25 13:26:31 Tx RF HouseUnit: A1 Func: On
04/25 13:26:31 Tx PL HouseUnit: A1
04/25 13:26:31 Tx PL House: A Func: On
04/25 13:26:36 Rx PL HouseUnit: A1


The last line is very odd because it indicates there is another X10 controller
transmitting on the power line. The CM15A does not see its own transmissions so
there must be another controller such as a CM15A, TM751, or RR501 transmitting
at the same. Please unplug all other X10 controllers and see if this helps.
It might make things worse since the other controller may be causing the
module to turn on/off.

Try changing to a different house code. The other X10 controller could belong
to a neighbor.

However when I issue the pl commands the devices do not respond (see below)

pl a1 on
04/25 13:30:28 Tx PL HouseUnit: A1
04/25 13:30:28 Tx PL House: A Func: On

pl a1 off
04/25 13:30:44 Tx PL HouseUnit: A1
04/25 13:30:44 Tx PL House: A Func: Off


This looks fine to me and SHOULD work.

What is the model number of the X10 module?
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: bakelite on April 26, 2011, 10:41:39 AM
My unit is a UK CM15, however I may have identified the problem today :-)

I reconnected my old serial UK CM12 and made a few tests using Heyu. It worked however I noticed the device response was over 10 seconds. Reading the Heyu forums this type of slow response is thought to be due to a poor quality power line.

So I moved my whole setup round to a friends house (different power cct) where everything works perfectly :-)

So even though my original testing was on a single power outlet noise must be filtering back up to swamp the X10 signals. When it worked via the rf command it must have been my RF transceiver (the other device you noted) putting out a stronger signal than the CM15. I will now try and isolate the noise. Thanks again for all your help and a brilliant driver.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: dattas on August 02, 2011, 10:25:33 PM
mmauka,

I love this, I just got it working on Ubuntu server 11.04 64bit. The only change to version 0.1.12 I had to make was remove the 3 lines in mochad.c starting at line 514.
So I just had to change
Code: [Select]
512     if (r < 0) {
513         libusb_cancel_transfer(IntrOut_transfer);
514         while (IntrOut_transfer)
515             if (libusb_handle_events(NULL) < 0)
516                 break;
517         return r;
518     }
to read:
Code: [Select]
512     if (r < 0) {
513         libusb_cancel_transfer(IntrOut_transfer);
514         return r;
515     }
without this change the code would get stuck in that while loop until kill -9'ed. I figured this was an okay change to make since in your main loop you call the handle_events anyway but with the timeout so things won't get stuck.

Also, debug mode doesn't work as it gives you the error
Quote
unknown option -d
unless you make line 807 in mochad.c, which looks like:
Code: [Select]
807         if (strcmp(argv[i], "--raw-data") == 0) to read:
Code: [Select]
807         else if (strcmp(argv[i], "--raw-data") == 0)Thanks for the hard work!
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: NavinR on August 24, 2011, 03:14:14 PM
MMauka,

Thanks for this most excellent app!

I use mochad on a pogoplug and it works perfectly.  I also use a micasaverde Vera 2 z-wave controller.  A Vera user has written a plugin that allows communication between the Vera and mochad.  This allows me to control X10 via the Vera, and to trigger scenes from X10 RF devices.  It works really well.

Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: doogie on November 27, 2011, 04:55:39 PM
Hello,

I'm using Marmitek SW12 with mochad and Openremote to control my Window-Sunshades.
It's working quite well with ON and OFF commands, also DIM and BRIGHT can be used to lower or raise the blinds a certain amount.
But I'm not able to get the XDIM command to work. I want to set the blinds to 50%, with a "PL B10 XDIM 50", but it doesn't move.

I'm trying this through Openremote AND directly from the command shell with
echo pl B10 XDMIN 50 | nc localhost 1099

nothing happens :(

The SW12 is clearly capable of moving to given positions, as with the Active Home Professional software you can do  this without a problem...
any idea how this could work?

best regards
Doogie
P.S.: using mochad 0.1.12
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: doogie on November 27, 2011, 06:18:30 PM
I investigated a little further and came to the following conclusion:
the Blind-shutter-Modules don't listen to XDIM, but to different extended codes, each extended code number is a specific position of the blind.

I had a closer look at how ActiveHome Professional handles it, and if you take a look in the Activity history, you see a major difference between ActiveHome and mochad/ncat:

if you try to "XDIM 96" the module with NCAT, you get the following result

TX PL HouseUnit: B10 Func: Ext Code 1, Data, Control Data, 60

when controlling the SW12 modul at address B10, you get the following entries:

TRANSMIT B10 Extended code 18 1


*) B10 is the address,

*) 18 is the hex value for the position. There are 25 Positions, in 4% steps between 0 and 100. 18hex = 24 = 24*4 = 96% open. If you "dim" it to 8%, you get a "Extended code 2",  60% is "Extended code F", and so on... so, the range is between 0hex and 18hex.

*) 1 seems to be a fixed value


now, the major question: is this possible in mochad, maybe in an updated version?
Will gladly volunteer for testing...

regards
Doogie
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: dhouston on November 27, 2011, 07:48:16 PM
The extended codes are defined in this document...
although I do not know whether that is the final version.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: doogie on November 28, 2011, 01:25:10 AM
thank you, I saw that too, but that could only be a guide how to modify the mochad source code, right?
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: doogie on November 28, 2011, 05:49:58 AM
after reading into the document again and comparing it with the sourcecode and WIKI, maybe the passthrough ("PT") command could be a workaround...
Will test that at home tonight...

a " simple"
Code: [Select]
PT 5a 05 07 e7 09 12 01
should set the blinds at B10 to roughly 50%, hopefully...
will report back with the result...

Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: dhouston on November 28, 2011, 06:59:09 AM
thank you, I saw that too, but that could only be a guide how to modify the mochad source code, right?
It can tell you whether or not mochad is sending the codes as defined in the document as well as serve as a guide for modifying the source if that's where the problem lies.

AFAIK, X-10 never sold any devices in N. America beyond control for lights/appliances so experienced users of most of these codes are only likely to be found in Europe.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: doogie on November 28, 2011, 07:07:26 AM
It can tell you whether or not mochad is sending the codes as defined in the document as well as serve as a guide for modifying the source if that's where the problem lies.

... and if I spend a few more hours in decyphering this pdf, maybe I can get a passthrough command to work... not sure about my PT example from before, but maybe someone has experience with this raw commands, and can help me a bit?

I think with PT-commands, it should be possible to achieve anything that the new devices support, no matter if it's already implemented in mochad or not...
Just have to figure out the correct syntax AND the correct mapping of the adresses (just learned that house "B" is encoded as hex "E"...)

anyway, don't giving up yet...
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: doogie on November 28, 2011, 01:02:33 PM
Heureka, it works!
 -:)
a little bit of adjustment to my initial idea, but now it's satisfying:

Quote
pt 07 e7 0F 0F 01

PT: passthrough
07: extended command
e7: e=house B, meaning of 7 is unknown
0F: meaning of 0 is unknown, F = unit 10
0F: Position 15, little bit below the middle
01: Codetype for shutter codes


only thing that could be difficult now is implement this in a slider, as the  ${param} is giving decimal values, and mochad/X10 is expecting hexadecimals...
but will try it anyway

thanks dhouston for making me read the document over and over again today, otherwise I would have discarded it as too complicated  :)
and congrats to mmauka for developing such a fine thing like mochad, very pleased with it's possibilities!

regards
Doogie
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: Deemar on June 08, 2012, 06:07:03 PM
Which software are you guys using with this driver? Heyu? Is it really working? I'm thinking about buying it and upgrading from my CM11A.
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: shake on September 28, 2012, 08:31:46 PM
Hey guys, I'm brand new to this a I'm sorry if I'm asking something redundant.

I'm using mochad on ubuntu, I wasn't able to get heyu or other drivers I downloaded compiled and running properly. In other words I defaulted to mochad because I got it set up quickly and it does most of what I want very well.

I just received a used rcs tx10b thermostat. I have a bi-directional x10 pl interface with it, but I cannot get bi-directional traffic working. According to the thermostat manual I need to send a preset dim command of 27 to address P4 for the therm to turn on transmit/bidirectional. I've tried various commands in mochad and various in ahcmd.exe but I'm pretty sure I'm simply not doing it right. dims, xdims, presetdim1,2 dont seem to work.

I need this so I can query the temperature from the head unit. Any advice or request for specifics?
Title: Re: mochad, X10 CM15A/CM19A Linux device driver
Post by: bbx10node on September 29, 2012, 04:11:21 AM
The mochad command
pl a4 dim 26
should do the job. Preset dim in mochad range from 0..31 but the thermostat manual shows dim levels from 1..32 so just subtract 1.