X10 Mochad to MQTT Gateway Addon

Just getting started with Home Assistant, and I still have some X-10 devices that I wanted to use with HA. Tried the Mochad integration in HA, but it wouldn’t do the things I wanted to do like triggering automations from X-10 rf remote keypads and motion sensors. I found something called mochad-mqtt on github and at its core is a Perl script which creates a gateway between Mochad and MQTT. It only supported powerline devices, but I modified it so it would also support RF devices. I ran it on a separate Linux machine for a while, and it was working fine.

I wanted to run it on the Raspberry Pi with HAOS, and it seemed the best and safest way was to make an HA addon. I did that and while I haven’t done extensive testing, it is working for me. If anyone is still using X-10 devices and wants to try it, I put it on github. GitHub - jeffs555/mochad-mqtt-ha-addon: Home Assistant Addon for X10 - provides gateway between Mochad and MQTT

2 Likes

Already using the Mochad integration for a few X10 switches over CM15A but the HA integration needs to receive a first command on startup to “wake up” and create the entities so I’ve been using command_ line switches as a workaround.

But since you are coming with a new option, I tested and am getting the following in the log:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
2023-10-28 17:02:20.644745 -0400 error main: Unmatched: 10/28 17:02:20 RfToPl 0000

That is is how it comes up when it is working correctly. That Unmatched: error just means that it received a Mochad command or response that it does not handle so it just ignores that command or response. When the script starts, it sends a RfToPl 0 command to tell the CM15a not to echo rf commands onto the powerline. The RfToPl 0000 is the acknowledgment from Mochad that it did turn off the echo correctly but the original mochad-mqtt had nothing to check the acknowledgment. I was going to add something, but never got around to it.

Thanks for the feedback; you are right, it does work despite the log error.

some observations:

  • I didn’t need the Mochad add-on from FloridaMan7588; I just have mochad on a separate Linux Vbox and the standard HA Mochad integration. So not sure what the other add-on purpose is?

  • documentation says “State is saved for switch, light, and sensor”; not sure what this means but state doesn’t survive restart (becomes “unknown”) which I believe is the standard HA behavior when state is not reported or a new command issued. This is something debated over the forum ; users (including me) asking to optionally maintain last known state:

There was no documentation for the original mochad-mqtt and I just tried to document a little of what I saw in going through the Perl script. He does save the state in a file and I assumed it would be restored on reboot, but apparently not.

1 Like