Need help getting X10 working

Hi, I’m just getting started with HASS, but I’ve been using one HA system or another for the past 15 years or so. As such, I still have some legacy X10 devices I’d like to continue to use. I’m trying to get Mochad working with HASS but I’m having some troubles.

My configuration.yaml contains these lines:

mochad:
  host: localhost

switch:
  - platform: mochad
    devices:
      - address: b3
        comm_type: rf
        name: x10switchb3

I can see this in the interface and get no errors so I think my configuration for HASS is okay. I’m using HASSbian image on a RPi3 using a CM19A. I installed mochad per the instructions. I do have one oddity in that I can only run mochad using ‘sudo mochad -d’ . I’m not sure what the issue is there, but I have had the same thing happen to me when running OpenHAB but mochad functions despite the odd way I have to start it.

Any help with getting this working would be most appreciated. I only really use the PalmPad Remote Control units but we use them very often so this is one of the critical things I need to get going before I can switch to HASS. I’m open to any other X10 options that might be available.

Thanks again for your time!

Using a combination of systemd and a udev rule, you can fix the startup problem, but that’s pretty far into the weeds for now.

Can you talk to mochad from the command line?

See here for examples: https://sourceforge.net/projects/mochad/files/?source=navbar

With netcat? Yes… I can send commands … I tried the X10cmd you wrote and it works so communications are working. I’m only interested in the button presses on the remote so I really need the receiving side to work. I do see data come in when I press the buttons on the remote so that appears to be working too.

By PalmPad, I assume you mean something like an HR12A?. If I’m guessing what you are trying to do correctly, you want to be able to control your X10 devices with the palmpad and have the device state updated in HA?

That won’t work with the mochad controller currently as it does not have support for querying X10 device status.

Sorry… I was not descript at all in what I want to do. I’m currently using OpenHAB and I use the X10 remote (HR12A) as an easy way to do this:

Button B3 -> ON -> Triggers a rule that turns on Zwave lights in living room
Button B3 -> OFF -> Triggers a rule that turns off Zwave lights in living room

Button B4 -> ON -> Triggers a rule that raises current cool set point on Zwave thermostat by one degree
Button B4 -> OFF -> Triggers a rule that raises current cool set point on Zwave thermostat by one degree

Button B5 -> ON -> Triggers a rule that turns on whole house fan (Zwave thermostat)
Button B5 -> ON -> Triggers a rule that turns on whole house fan (Zwave thermostat)

So really it’s just a simple input device.

Is this possible with mochad? The remote buttons are very similar to what a motion detector would send. I’m guessing that those work in Home Assistant via mochad?

Thank you again for taking the time to help. I am on gitter chat if you prefer to communicate that way.

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:

pi@raspberrypi:~/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
pi@raspberrypi:~/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…
pi@raspberrypi:~/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