Home Assistant Add-On: X10 (CM11) to MQTT Gateway

This addon does not have dimming capability (yet???). Read the posts above. I setup dimming presets years ago by configuring routines in my IBM Home Director software, which were then programmed into the CM11A many, many, many years ago. These routines each have their own House/Unit Code pair. There is a routine for [pair] ON, and one for [pair] OFF.

When Mark Motley created this add-on, I just had to point Home Assistant to those House/Unit Code pairs. This was basically the same translation that enabled me to easily control my X10 with Alexa using the HA-bridge on a Raspberry Pi five years ago, long before I dove into the Home Assistant ocean.

Are you complaining? You (as did I) paid money for Home Director software. Both of us paid nothing for this add-on. You were one of the first to use this add-on. So you should be aware Mark himself doesn’t have any X10 hardware. He said so in the very first post. He was hoping his neighbor may have some dimming X10 modules. Perhaps the neighbor doesn’t any. If you had dimming modules, you should have offered to help back when he was developing the add-on, as I did with the FireCracker. I don’t have any dimming modules either.

If you not happy with this add-on, don’t use it.

If my comments sound like complaining to you, I would likely not be able to please you with any amount of praise. I personally am very pleased with this add-on, as I clearly stated on May 10. I was responding to the question from webtense with regard to dimming (brightness).

The last post from the OP was that he “may have access to a dimmer module…next week” back in mid-May. If Mark still has availability to continue working on this project, but needs some bit(s) of hardware to proceed, I am more than happy to send him a dimming X10 lamp module.

And could you share with me how you have done it.,. I adapt to everything

thxs

Hello all,

i’m using HA Supervised.
I have heyu standalone installed, it works fine with my CM11 interface

root@AD110-HOMEASSISTANT2:~# heyu info
starting heyu_relay
Heyu version 2.11-rc3
Configuration at /etc/heyu/x10.conf
Powerline interface on /dev/ttyUSB0
Firmware revision Level = 8
Interface battery usage = Unknown
Raw interface clock: Mon, Day 030, 02:04:55
(--> Civil Time: Mon 31 Jan 2022   02:04:55 EET)
No schedule has been uploaded by Heyu.
Housecode = G
0 = off, 1 = on,               unit  16.......8...4..1
Last addressed device =       0x0040 (0000000000000001)
Status of monitored devices = 0x0001 (0001000000000000)
Status of dimmed devices =    0x0000 (0000000000000000)

mosquitto seems to work, this is from addon log file:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[01:23:27] INFO: Configuring Heyu...
[01:23:28] INFO: CM11 is enabled
starting heyu_relay
Establishing MQTT to 10.107.1.23 port 1883...
(Using MQTT username admin)
Waiting for MQTT messages and monitoring for remote changes
Connected to MQTT broker, result code 0

when i’m switching on the light, this is from the home-assistant.log

2022-01-31 02:13:11 DEBUG (MainThread) [homeassistant.components.mqtt] Transmitting message on x10/cmd/g1: 'ON', mid: 8
2022-01-31 02:13:17 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on x10/stat/g1: b'ON'

but the addon’s log, says that it cannot find heyu…

Received: x10/cmd/g1 OFF
Sending X10 command to homecode G1
Error running heyu, return code: 1
Device Status Update: x10/stat/g1
Unable to send address bytes
Received: x10/cmd/g1 ON
Sending X10 command to homecode G1
Unable to send address bytes
Error running heyu, return code: 1
Device Status Update: x10/stat/g1

this is where i stuck… any help would me appreciated.

My guess is that the Heyu relay is running on the main OS and perhaps tying up the serial port.

Addons are Docker containers, so a version of heyu is installed within the container itself, if that makes sense. It doesn’t need heyu running in the main OS.

I say this because of your first code section:

root@AD110-HOMEASSISTANT2:~# heyu info
starting heyu_relay
Heyu version 2.11-rc3
Configuration at /etc/heyu/x10.conf
Powerline interface on /dev/ttyUSB0

Try shutting down heyu in the main OS and restarting the addon.

well, i killed heyu processes and everything started to work fine…
i was starting heyu through crontab, but there is no need…
when addon starts, it also starts heyu…

root@AD110-HOMEASSISTANT2:~# ps -aux | grep heyu
root        4307  0.0  0.0   1768   556 ttyUSB0  Ss+  00:11   0:00 heyu_relay
root        4316  0.9  0.0   1768   936 ?        Ss   00:11   0:01 heyu_engine
root        4322  2.1  0.1   1768  1324 ?        S    00:11   0:03 heyu monitor

thank you very much… it works… it is very slow, but since i have 16 din rail switches/dimmers is very usefull…
if you can add dimming, it would be very nice…

Seconded, dimming is kind of a requirement for me, in order to move off the ancient platform I’m currntly using. There are at least two dimming styles: the original 16 step dimming from the early days and the extended dimming that came along later.

Hi, I’m having the same issue as PAOK1926:

Remote status change, publishing stat update: x10/stat/a1 is now ON
Received: x10/cmd/a2 OFF
Sending X10 command to homecode A2
Unable to send address bytes
Error running heyu, return code: 1
Device Status Update: x10/stat/a2
Received: x10/cmd/a1 OFF
Sending X10 command to homecode A1
Unable to send address bytes
Error running heyu, return code: 1
Device Status Update: x10/stat/a1

Receiving works fine, sending give this error. Unfortunately, I don’t have a ‘main os’ in which to shutdown heyu, as I’m running home assistant OS inside a VM. There’s nowhere I can issue a heyu command or see what processes are running. Any thoughts on this?

Edit:
I compiled Heyu on a debian server to check and see if my CM11A could properly send commands and it does. So, somewhere under the shroud, something is getting lost between this add-on and the hardware. Can anyone suggest how I might look under this shroud? I really don’t have the background or experience to go full on developer, but I’m willing to try to follow some suggestions…

Not trying to be a pest, but I’m still quite stuck on how to further debug this error. Anyone have any ideas?

Sorry for the delay, been very tied up with a work project the last few months (still am but had a break to respond).

And I’m not a developer by trade either (I’m an IT Infrastructure guy, mostly IP networking), which is why this is a bit of a kludge, I’ll admit. As mentioned in the release notes, it was thrown together to help a friend with a handful of X10 devices left, and I thought others might find it useful.

Worse yet, the CM11A I was using for testing died…

@g13092, if you’re running HassOS under a VM (which hypervisor are you using?), check to make sure HassOS can see the serial port attached to your CM11A. I know sometimes hypervisors have to be configured to do this.

Under the covers, ‘heyu’ simply attaches to the serial port like it would if you’re running in standalone. It does this by creating a simple x10.conf file with 'TTY '. However, the Docker container (which is what addons are) needs to be able to see the serial port from HassOS / your VM hypervisor.

If you go to Configuration → Addons, Backup, Supervisor, System tab, take a look at the hardware listed on Host and make sure HassOS can see the USB serial adapter.

You can also try using the full HassOS dev name as well. So, instead of ‘/dev/ttyUSB0’, which may change on reboot if you have other serial devices (e.g. Zwave, Zigbee, etc), you can try using the full ‘/dev/serial/by-id/…’ for the serial port in the add-on config. I did test this once and it worked.

Hope this helps…

Hi Mark,

That’s why I hate to pester, I know this is ‘volunteer’ work & we all have real lives… I’m always hoping some other smart user could chime in so you don’t have to do heavy lifting all the time. I do have an extra CM11A, pm me and I’ll mail it to you.

I’m running in Oracle Virtual Box, HAOS 7.4 and Core 2022.2.9. I did try your hardware config path suggestion, but no improvement. What’s interesting is that the heyu monitor is working, it sees and logs X10 commands coming into the cm11a from the powerline generated by another x10 controller. There only seems to be an issue sending out commands, so I suspect heyu attacheds fine to the serial port. I did confirm the CM11a I am using will send x10 messages initiated on the command line using Heyu 2.10.3 installed directly on another debian box I have.

I see in your main python in the execute “section”:

  result = subprocess.run(["heyu", heyucmd.lower(), housecode.lower()])
  if result.returncode:
    print("Error running heyu, return code: "+str(result.returncode))

Digging into cmd.c of heyu, I see the error phrase display_send_message("Unable to send address bytes"); in the send_address function, in the 5A checksum Kluge fix if statement. I tried a few different house codes to see if that would avoid dropping into this if statement.

The thing is, I have no idea how to get ‘inside’ the addon container and see if this is what’s going on. I’m used to using portainer on my OMV setup to see in some dockers, but I don’t see the same debian world when looking into HA through the HA CLI window. I’d love to get inside and issue commands to heyu from a terminal…

Best wishes on your IRL projects, Mark!

Note: the existing on/off support is enough to support X10 motion sensors, here is an example:

binary_sensor:

  - platform: mqtt
    name: "Kitchen Motion Sensor (x10)"
    state_topic: "x10/stat/c9"
    payload_on: "ON"
    payload_off: "OFF"
    unique_id: "X10-C09"
    device_class: motion
    device:
      manufacturer: "X-10"
      model: "Unknown"
      identifiers: "X10-C09"
      name: "Hawkeye II"

  - platform: mqtt
    name: "Kitchen Light Sensor (x10)"
    state_topic: "x10/stat/c10"
    payload_on: "OFF"
    payload_off: "ON"
    unique_id: "X10-C10"
    device_class: light
    device:
      manufacturer: "X-10"
      model: "Unknown"
      identifiers: "X10-C10"
      name: "Hawkeye II"

Defining them as the motion device class allows them to be used by the native Alarm or Alarmo Integrations. Edited to fix sense of Light Sensor.

1 Like

I am new to Home Assistant, but not to X10 . I have a CM11A and serial adapter which I would like to use in HomeAssistant.

I am running HAOS 2022.3.7 on a Raspberry Pi 3B+.

The instructions under “installation” on top don’t seem to apply to this version.
Supervisor seems to be in a different location, under Configuration / Add-ons, Backups & Supervisor / System . However, the only options under Supervisor are “Join beta channel”, “Reload supervisor”, “Restart supervisor”.

Add-on store is under Configuration / Add-ons, Backups & Supervisor / Add-ons / Add-on store (bottom right).

It took me some time to figure out those locations.

And then within add-on store, the vertical menu on the top right / repositories finally offers the option to “manage add-on repositories”. That’s really a lot of levels to go through to add a repository.

The search bar (by typing c) doesn’t find any of this stuff.

Here is how the repository list shows :slight_smile:

Anyway, even after I added the repository, unfortunately, the “X10 to MQTT gateway” add-on did not appear at the bottom of the add-on list. I see two lists, one called “Official add-ons” and the other “Home Assistant Community Add-ons”. The “X10 to MQTT gateway” is not in either of these. The search function at the top of the Add-on store does not find anything when searching for X10

Is there something else I have to do to get the add-on to show up ? I did not try restarting HAOS yet. I have some automations in progress that I don’t want to interrupt.

The supervisor/configuration menu has changed since. Anyway, I think you have to click on the “mmotley999…Repository” in that Manage add-on window first. I haven’t add any external add-on since the menu changes.

Thanks for responding. I tried clicking, but all it does is highlight the repository. Nothing else happens. The only thing I can do is click the trashcan icon to delete it, or close the pop-up.

BTW, I restarted HAOS, and the add-on still didn’t show, unfortunately.

After adding repository, you shd see it at bottom of addon store.


Check the log to see what’s wrong. Not sure if one has to add the mqtt integration first. Else, I really don’t know. Sorry, out of ideas.

Thanks for helping. It’s definitely not there at the bottom :

I didn’t see anything related to this repository in the log.

It would make sense that a separate MQTT component would need to be installed, but Mark’s instructions at the top of this thread don’t mention that, or how to do it.

I just restarted HAOS one more time, and now the add-on finally showed up in the add-on store. Literally didn’t do anything else. I tried to install it, but there was a network error.

I just used the “stop server” option, and then cut/restored power to the Pi. It came back up. This takes much longer than the “restart server” option. Looks like “restart server” just restarts the daemon, but does not reboot the OS.

I have been making changes to my network in recent days, running my own DHCP server for a portion of the IPv4 subnet, on a separate Pi, because my Comcast router’s DHCP server cannot handle the number of devices I have (>64 triggers bugs). This could be related. I have seen HAOS lose its IPv4 address - reverting to the default IPv4 autoconfig address, and not try to request another IPv4 address again until manually powered down like I just did. HAOS remained accessible with IPv6, though. Other devices appear unaffected, so far, though I haven’t checked them all.I have smokeping disabled temporarily as my devices have all changed their IP reservation recently. On my todo list to reconfigure it and restart it.

Anyway, I finally have got the add-on installed now. Time to RTFM and configure the serial adapter with it.

For the record - my is HAOS 2022.3.5 on a Pi3B+.
Mark may hv assumed mqtt is already installed? My mqtt was installed long b4 Mark’s X10 came along. Easiest way is the Mqtt integration via configuration/integration/add integration. Suggest you do that b4 config X10.

Also, to reboot, always do configuration/settings/check configuration first, then restart. Else if you hv a mangled configuration, it may not restart.