[Solved] Newbie trying to get MochadX10 working with Openhabian

Hi, here is what I have done so far:

  1. Discovered that the MochadX10 binding will NOT work with my OH3 installation. So, I did a fresh openhabian install of 2.5 on another R-Pi, and installed the MochadX10 binding - all seemed to go well. Check.

  2. Discovered that the binding does not actually install Mochad itself, but expects the server to be at a port like 1099. So, I followed the process to install Mochad on the same R-Pi. Seemed to go well. Check.

  3. Here is where I am stuck currently: I see the following messages in /var/log/messages from the startup:

Sep  5 17:44:50 openhabx10 mochad[221]: starting
Sep  5 17:44:50 openhabx10 mochad[224]: Found CM19A
Sep  5 17:44:50 openhabx10 mochad[224]: In endpoint 0x81, Out endpoint 0x02

This seems good, but it doesn’t look like any 1099 port is actually open and listening:

openhabian@openhabx10:~ $ netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0  *               LISTEN     
tcp        0      0   *               LISTEN     
tcp        0      0    *               LISTEN     
tcp        0      0   *               LISTEN     
tcp6       0      0          :::*                    LISTEN     
tcp6       0      0 :::139                  :::*                    LISTEN     
tcp6       0      0 :::5007                 :::*                    LISTEN     
tcp6       0      0 :::8080                 :::*                    LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 :::8443                 :::*                    LISTEN     
tcp6       0      0         :::*                    LISTEN     
tcp6       0      0 :::445                  :::*                    LISTEN     
openhabian@openhabx10:~ $ 

And sure enough, when I try to connect and give it the commands like

echo "rf a1 on" | nc localhost 1099

nothing happens. However, if I actually launch Mochad in one terminal window, and then issue the above command from another, the light actually does go on, proving that the Mochad installation, as well as my CM19A are perfectly functional.

Does all this make sense to someone? What am I doing wrong? Thanks.

OK, after much googling, I discovered that Mochad has been broken on Raspbian since Jesse (circa 2015). There is a discussion of what is broken about it here.

There is a “fix” that was committed into a branch but never made it mainline. The steps for incorporating that fix is given here.

Note that there are a couple of issues with the fix:

  1. It’s missing one step in the step-by-step of instructions. There should be:
3.5 cd mochad-master
  1. When the make install finished, I got an error, something to do with LIBUSB_ERROR_BUSY. However, this was resolved by rebooting the Pi.

  2. As noted in the sourceforge thread, if you ever unplug your X10 interface from the USB and re-plug it, it will not recover. Easiest thing is to just restart the Pi.

Anyway, this gets me past the point where I was stuck. Now, I have to figure out the arcana of OH 1.x bindings and how “things” and “points” work there. Onwards. That’s what I get for using grandpa tech like X10 I suppose…

Back in the dark ages (2014) I used mochad and here is the notes I did back then:

2014-01-04 Added /etc/udev/rules.d/40-permissions-cm19a.rules and put this in it: SUBSYSTEM==“usb”, ATTRS{idVendor}==“0bc7”, ATTRS{idProduct}==“0002”, MODE:=“0660”, GROUP:=“cm19a”, SYMLINK+=“cm19a”
Then installed mochad program. then you can send rf by starting mochad and issuing command echo “rf j1 off” | nc localhost 1099
You need to get this otherwise the compile fails: apt-get install libusb-1.0-0-dev
135 wget Download mochad from SourceForge.net
136 mv download mochad.tgz
137 tar -xf mochad.tgz
138 cd mochad-0.1.16/
139 ./configure
140 make
141 make install
142 mochad
143 ps -ef|grep moc
144 echo “rf j1 off” | nc localhost 1099
145 echo “rf j1 on” | nc localhost 1099
146 echo “rf j1 off” | nc localhost 1099
147 nc localhost 1099

The above was taken from the bash history file.
Don’t know if it will help you or not but good luck.

Thanks Greg, yes that would have worked in 2014, but not since the 2015 release of Jessie on the Pi. The solution I posted above does work, however, with some of the limitations noted.