[Release] X-10 Devices using Mchad or Heyu with Node Red bridge

Hubitat Apps and Device Handlers for X-10 Devices using Mchad or Heyu with Node Red bridge

******Please note that I am not maintaining this any more. Gave up on X-10 and moved on to Zigbee/Z-Wave things. This has worked for many people, and for some its been nothing but heartache and frustration for others, sincerest apologies @Chad_Heminger . I never had Heyu always used mochad so this was done with help of others in ST community and ported to HE pretty much untested. Reading the original post again, I see that point is not made and I apologize for wasting anyone's time. *****

Seems like @Chad_Heminger has found a better solution link in post 5 below

All code is in github and other repos, use if you want, or not. It was fun while it lasted. There is a lot of good discussion here and in ST forums, if you are interested you can fork and do your own thing. ****

Image of Logo

This solution allows 2-way communication between Hubitat and X-10 devices using Node Red and Mochad. You can control your X-10 devices from within HE and use various automation solutions within HE. You can also use X-10 remotes and motion sensors to control other devices. X-10 equipment is fairly inexpensive and readily available on E-Bay etc.

In this solution all X-10 settings and device mappings are done using the Hubitat app. Only a couple of one-time settings need to be made on the Node Red flow.

See the orginal ST page for details and user discussions

Changes from ST Version

  • Uses telnet connections for more robust connectivity between node red server and HE. The default TCP port is 1025, you may need to change it, if its not available on the machine where you are running the node red server

  • Device P-15 is reserved for pinging the system to maintain connectivtiy every 30 minutes. If you need to use this device for something else you can change it in x-10-node-red-mochad-device.groovy

  • Heyu functionality has NOT been tested, since I don't have a heyu device. For ST a heyu user worked with me to do the implementation. If anyone is interested ping me, if you can compare it code and make the changes yourself, feel free to send me a PR

Supported Devices and Functionality

  • X-10 Switches and Modules - on/off and dimming are supported

  • X-10 Motion Senors and Remote buttions - on/off funtions supported from devices sending housecode/unitcode on/off commands

  • X-10 Security Devices

Please note: Dimmer functions are a bit wonky - don't rely too much on percentage just treat them like up/down buttons becaue that's what is available on physical X-10 devices. You can get percentages almost right, if you caliberate by setting to 0 and physically dimming to dark, but it remains dicey, there is no good solution to it.

Requirements

Raspberry Pi

These instructions are for Raspberry Pi, but they can be easily adapted to any Linux variant

Mochad and CM15A or CM19A USB Devices

Mochad exposes a TCP interface to X-10 commands, and can run on any linux system including Raspberry PI. It uses CM15A or CM19A USB devices to communicate with X-10 over RF or powerline. Using these devices you are not limited to a single house code, you can use any of the 15 house code with any x-10 device.

https://bfocht.github.io/mochad/

https://bfocht.github.io/mochad/mochad_reference.html

Node Red

Node-RED is a programming tool for wiring together hardware devices, APIs and online services using a browser-based editor. Node Red is very simple to deploy and is very light-weight. Requires very little effort to setup and run

https://nodered.org/

https://nodered.org/docs/hardware/raspberrypi

Setup


Step 1: Install Mochad on Raspberry Pi

Follow any number of tutorials to setup your Raspberry Pi using your favorite distro, make sure you install the development tools. On Raspbian you can do this using the following command

> sudo apt-get install build-essential

Build mochad

  • Install libusb-1.0.0 development files. mochad will not build without this.

> $ sudo apt-get install libusb-1.0-0-dev

  • Get mochad source code and unpack it.

> $ wget -O mochad.tgz Download mochad from SourceForge.net

> $ tar xf mochad.tgz

> Now build mochad.

> $ cd mochad*

> $ ./configure

> $ make

> $ sudo make install

  • Edit /etc/udev/rules.d/91-usb-x10-controllers.rules change the following line to :

> RUN+="/usr/local/bin/mochad &"

This ensures that mochad will load whenever the usb device is detected, include when Raspberry pi reboots

Blink a lamp

  • Plug in a CM15A, CM19A, or CM15Pro into a Raspi USB port. Connect a lamp to X10 module set for address A1.

  • If using a CM15A or CM15Pro try the following power line (pl) commands.

> $ echo "pl a1 on" | nc localhost 1099

> $ echo "pl a1 off" | nc locahost 1099

  • If using a CM19A try the following radio frequency (rf) commands.

> $ echo "rf a1 on" | nc localhost 1099

> $ echo "rf a1 off" | nc localhost 1099

At this point you should make a list of commands that you need to turn your X-10 devices on and off, you will need this later.

credit - X10 Linux: Installing mochad on a Raspberry Pi

Step 2: Install & Setup Node Red

Install Node Red

Follow the instructions on this page to install Node Red on your Pi Redirecting…

Play around a little bit to get the hangs of the basics

Setup Node Red

Step 3: Add the Apps and Drivers Code in Hubitat

You will need to install the following Apps and Drivers in the appropriate sections - make sure you install all of them

Step 4: Add App to Hubitat and configure X-10 devices

  • Add the X-10 Node Red Bridge Parent App in the Apps section in Hubitat IDE using 'Add Usser App' functionality

You will need to select the hub and configure IP address and port for the Node Red server - this should be the same IP address you use to connect to Node Red on the browser. Port is specified in the first node in the flow, it defaults to 1025 - ensure that you are using the same port on both sides

  • You can then add X-10 devices in Hubitat and set their X-10 addresses.

Once you add a switch you should be able to turn it on and off. You can map remote buttons and motion sensor address to any device that supports on/off function and control it.

Thanks for the tutorial. I haven't finished it yet but I discovered one problem involving mochad that I thought might help someone else.
I spent a whole day trying to get mochad to work until I found this post:

https://www.sigmdel.ca/michel/ha/domo/domo_08_en.html

The gist of the problem is Sourceforge considers 0.1.16 to be the latest version (as of 6/26/2019) but it has problems in Raspian Jessie. Version 0.1.17 has a fix for this problem. I replaced the line:

wget -O mochad.tgz http://sourceforge.net/projects/mochad/files/latest/download

with

wget -O mochad.tgz https://sourceforge.net/projects/mochad/files/mochad-0.1.17.tar.gz/download

and every thing else worked fine.
I'm sure Sourceforge will fix this at some point so be sure to check

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

Again, thanks to enishoca for this great tutorial and to Michel Deslierres for the fix for my Raspian Jessie on my Pi 3+.

Also, to check the mochad installation, try the suggestion in Michel's post:

sudo systemctl status mochad

both before and after plugging in your CM15A or CM19A devices.

Now for setting up Node Red!!!

1 Like

Thank you - I have updated the main post. My Pi was built long ago and there has been no reason to rebuild it.

I have Been following the SmartThings link that was mentioned in the opening post.

It seems someone has commented out a few lines, or set it to verify that the desired change has been executed. I don’t know if it has been added to the hubitat node-red.

I am having a problem with an automation. I am trying to set every switch to the off position via a rule machine. The problem I am seeing is when the hubitat sends “off” the node-red reads the current state and just changes it. If the device is off, it just changes it to the opposite status and turns it on. (If it is on, it turns it off). When I run it again, it again switched to the opposite status of the current light.

Rule machine:

Log file:

I thought it was rule machine problem, but now I think it is a nore-red /mochad problem.

Is anybody looking at this post anymore?

I gave up on this post and followed this post.

It works so much better!

Just installed apps/drivers on RPi 4. Fantastic work/documentation.
Thank you very much :grinning: :grinning: :grinning:

Minor nit, SmartThings is in "Remotes and Sensors" config

Thanks

It appears that there is no ability to turn off debug statements on logs.


Also when creating remote X10 devices ie buttons, no button devices are created in HE, so you're not able to create automations, either RM or Simple Automations or Button Controller apps. Forces creating VS , controlled by X10 button, and using that VS as trigger in apps.
Thanks

I must say that I am surprised this does not get a lot of play. I have been using this app since day 1 and love it. I also know that the developer is willing to help with any issue. If I recall we actually talked on the phone and he helped me tremendously. Keep up the great work. This has saved me so much money utilizing my old x10 devices. If anyone has any that you want to donate to me feel free :slight_smile:

I use it extensively, all my outside outside lights (floods, etc) are X10

I asked this somewhere else...I have used node-red for a long time back when I was using ST. Have devices all over my house. However, not sure why, but my lamp modules now flicker. They do have LED bulbs but it did not happen with ST. Not sure what has changed. Anyone else see this?

In my experience w LEDs w either X10 plugin sockets or lamp sockets, it's hit or miss. They could be stable for years, then start flickering. X10 was not designed LEDs...

Well it was working for a while and now nothing works.. I see the msg dialog is producing the right message
03/07 06:34:40 Rx RF HouseUnit: A1 Func: On
03/07 06:34:40 RfToRf repeat

Then I get
"Warning: msg properties can no longer override set node properties. See bit.ly/nr-override-msg-props"

and every once in a while I get "Error: connect EHOSTUNREACH 192.168.158.111:80" but my machine is not 111 it is 112. Everything seems to be set correctly.

Help would be appreciated

I'm using PLC, not RF. Any WiFi chnages lately ?

I would like to use PLC but I have so many fuse panels and solar that I really don't think it will work. In the Bode red I can see that it is connected and as you can see above that it is hearing the remote it just is not doing anything with it. I may try to remove everything and start over, I am currently using a VERY OLD Samsung laptop running Ubuntu and under ST it ran for years and was working for a little while with HUbitat but now nothing

Can you turn device on w echo "rf a1 off" | nc localhost 1099 at cmd prompt ?

OK I run the command and it echos back. I have the flows in but nothing is happening. In the debug window in node red it can see the commands coming in but again nothing happens

Likely your X10 RF transceiver is caput

Well...I have another on.....let me see if that one works.

All good after a total reinstall........Check that Why would I have to restart my flows to get it to work. Why dont they start right off the bat