Need help getting X10 working

Ah gotcha,

Sorry to say there is nothing like that currently. mochad itself would recognize the button press events, but the mochad controller would not.

Let me make sure I understand. You’re saying that mochad controller can send commands (like B3 ON) but it can’t receive commands like I’m trying to do?

Yes. If you send B3 on using Home Assistant, the controller does not read the state from the mochad daemon and Home Assistant simply assumes B3 is now on. If another device or controller sends B3 off, Home Assistant will not be notified and Home Assistant will still show the device as being on.

Please forgive me for continuing to bother you. I think that this may be what I need to solve this problem https://github.com/ChrisArgyle/mochad_dispatch … Unfortunately I am such a newbie with python that I do not understand how to compile/set it up. It uses a setup.py file. I tried this and it did not work:

[email protected]:~/mochad_dispatch-master $ python setup.py install

Traceback (most recent call last):
File “setup.py”, line 1, in
from setuptools import setup
ImportError: No module named setuptools
[email protected]:~/mochad_dispatch-master $ sudo pip3 install -U pip setuptools
Downloading/unpacking pip from https://pypi.python.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408f196358da3/pip-9.0.1-py2.py3-none-any.whl#md5=297dbd16ef53bcef0447d245815f5144
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB): 1.3MB downloaded
Downloading/unpacking setuptools from https://pypi.python.org/packages/3a/fb/570e51a1a4b0de85eb6ec36a6c47bd5fd7a55128a1391a15b6e21d290a87/setuptools-32.2.0-py2.py3-none-any.whl#md5=2404f0cf4ea2a006fdffe3ff868cb50c
Downloading setuptools-32.2.0-py2.py3-none-any.whl (477kB): 477kB downloaded
Installing collected packages: pip, setuptools
Found existing installation: pip 1.5.6
Not uninstalling pip at /usr/lib/python3/dist-packages, owned by OS
Found existing installation: setuptools 5.5.1
Not uninstalling setuptools at /usr/lib/python3/dist-packages, owned by OS
Successfully installed pip setuptools
Cleaning up…
[email protected]:~/mochad_dispatch-master $ python setup.py install
Traceback (most recent call last):
File “setup.py”, line 1, in
from setuptools import setup
ImportError: No module named setuptools

Do you have any tips for me on what is going wrong and how I might fix it? Thank you again.

I don’t think that’s going to work either. It only recognizes X10 RFSec messages (motion sensors and the like). It ignores regular X10 commands.

Are you sure? All of my X10 devices are RF based. The remote control is and I do have some motion detectors that I may or may not use. I just don’t know how to get the dang thing set up. Thank you for your patience. I’ve been working on HA stuff for a long time but I’m still very green when it comes to building things when problems arise.

I can’t spend more time on this today, but I’ll see what I can do over the holidays.

Thank you kindly and thanks for the information you’ve provided.

I thinking I’m getting closer with getting things to work. I’ve got mochad_dispatch installed and I THINK it will work.

Can you tell me about the udev rule and systemd I need to get my startup problem with mochad working?

Thanks so much. I think I’m almost where I need to be as far as all my hardware being up and running and ready to start automation.

/etc/systemd/system/multi-user.target.wants/mochad.service:

[Unit]
Description=Start mochad service

[Service]
Type=forking
ExecStart=/usr/local/bin/mochad

[Install]
WantedBy=multi-user.target

/etc/udev/rules.d/91-usb-x10-controllers.rules:

SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="0bc7", ATTR{idProduct}=="0001", RUN+="/bin/systemctl --no-block start mochad.service"
SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="0bc7", ATTR{idProduct}=="0002", RUN+="/bin/systemctl --no-block start mochad.service"
2 Likes

Is there a way to recognize normal X10 commands in HA from Mochad? This is the only missing part.

I thought sure I had posted this before but my solution for receiving commands from X10 is to run this:

/bin/nc -d localhost 1099 | /usr/bin/awk -W interactive ' /HouseUnit:/ && /Func:/ { system("mosquitto_pub -q 1 -t /X10/"$6" -m "$8) } ' &

This will send all X10 received commands to MQTT and from there you can do whatever you want with the payload. I’ve copied that line to a script file that I call using cron on reboot. It’s been working great for close to a year now.

1 Like

@dinki , thanks for the script., however this only passes through RF based commands and not all X10 received commands that PL based. Tried all possible variations.

@vicom what devices are not being picked up? I use this for both RF and PL. I tweaked it for a separate command to correctly parse X10 security devices.

@netrunner, all command sent through as PL are not being processed by the script. only my RF MS13 modules. I use the MT10A with buttons to turn on/off X10 devices via PL. The script doesn’t process the commands. I can see the command when i use “nc”. I think it’s because PL command are sent as two separate lines by Mochad , unlike the one line RF based ones. I might be mistaken. Care to share your script? TIA

@vicom I do not have a MT10A and the commands I see with “nc” for my single security device looks like this:

04/15 13:31:27 Rx RFSEC Addr: A1:C1:80 Func: Panic_KR10A
04/15 13:31:27 Rx RFSEC Addr: A1:C1:80 Func: Panic_KR10A
04/15 13:31:42 Rx RFSEC Addr: A1:C1:80 Func: Disarm_KR10A
04/15 13:31:43 Rx RFSEC Addr: A1:C1:80 Func: Disarm_KR10A

This is my cron job @reboot that intercepts that and converts to MQTT:

#!/bin/sh
#
# mochad to mqtt relay.
#
sleep 2
nohup /bin/nc -d localhost 1099 | /usr/bin/awk -W interactive ' /RFSEC/ && /Panic_KR10A/ { system("mosquitto_pub -V mqttv311 -t /HASS/X10/C16 -m On" ) }'
exit 0

@netrunner, I have the following when i “nc” mochad.

12/30 18:46:59 Rx RF HouseUnit: M11 Func: On
12/30 18:47:05 Rx PL HouseUnit: A5
12/30 18:47:06 Rx PL House: A Func: Off
12/30 18:47:13 Rx PL HouseUnit: A8
12/30 18:47:14 Rx PL House: A Func: On
12/30 18:47:17 Rx PL HouseUnit: A8
12/30 18:47:18 Rx PL House: A Func: Off

As you can see the “RF” commands come through as a single command, but “PL” as two …annoying
:frowning:

I don’t have any hardwired (PL) controllers. They are all wireless. I have a CM15A connected to the PI via USB and running Mochad. The CM15A is set to transceive all house codes from RF to PL so the log below is what I normally see on nc for my RF controllers, including MS16a motion detectors.

12/30 13:12:31 Rx RF HouseUnit: D5 Func: On
12/30 13:12:31 Tx PL HouseUnit: D5
12/30 13:12:31 Tx PL House: D Func: On

I’m sure with cleverness, you could modify the nc script or split it into two scripts with revised MQTT signaling to handle two line commands from X10.

Honestly the only reason I’m using X10 at all is because I have a ton of it from years ago and I like to puzzle through technical challenges! It works perfectly for me, but it took a lot of work to get it there.

Thanks … this solved my problems with mochad_dispatch. I augmented it slightly to a pattern for “Rx RF” so I don’t get multiple RF and PL entries.

/bin/nc -d localhost 1099 | /usr/bin/awk -W interactive ' /Rx RF HouseUnit:/ && /Func:/ { system("mosquitto_pub -q 1 -t /X10/"$6" -m "$8) } ' &

errror ? help me

Traceback (most recent call last):
File “/usr/local/bin/mochad_dispatch”, line 11, in
load_entry_point(‘mochad-dispatch==0.1.9’, ‘console_scripts’, ‘mochad_dispatch’)()
File “/usr/lib/python2.7/dist-packages/pkg_resources/init.py”, line 561, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/usr/lib/python2.7/dist-packages/pkg_resources/init.py”, line 2631, in load_entry_point
return ep.load()
File “/usr/lib/python2.7/dist-packages/pkg_resources/init.py”, line 2291, in load
return self.resolve()
File “/usr/lib/python2.7/dist-packages/pkg_resources/init.py”, line 2297, in resolve
module = import(self.module_name, fromlist=[‘name’], level=0)
File “/usr/local/lib/python2.7/dist-packages/mochad_dispatch-0.1.9-py2.7.egg/mochad_dispatch/main.py”, line 107
yield from asyncio.sleep(1)
^
SyntaxError: invalid syntax