Adding X10 support

I implemented a REST interface which HA can use, this is available at https://github.com/clach04/x10_rest

Work in progress x10 support for HA available at https://github.com/clach04/home-assistant-x10

Original post below


I have some X10 hardware, I know it is not as sophisticated as the new zwave stuff (e.g. no state reading information) I can’t justify moving to new kit when what I have works well enough for me :slight_smile:

I need some advice on how to add X10 support. Being selfish, I mostly care about my setup. Which is controlled by a (usb2serial adapter to) serial CM17A firecracker.

Options I’m considering but do not yet know enough about the HA framework/plugins:

  1. I think I’d like to avoid resorting to shelling out
  2. I’ve been using OpenHAB for a while and there is no support for serial CM17A firecracker but there is Mochad support (although there is no support for CM17A in Mochad!) My solution for OpenHAB was to implement a Mochad clone https://bitbucket.org/clach04/mochad_firecracker - is this approach worth pursuing with TCP binary sensors and TCP sensors or even adding Mochad support to HA?
  3. Similar to #2 is there any value in me using another fake server? E.g. Wemo or wemo switch by hacking https://github.com/makermusings/fauxmo (it maybe this implements the wrong UI so this is all high level speculation). There are other examples of this (for example, Philips hue bridge simulator)
  4. Adding a REST interface and hooking up to REST switch ?
  5. Implementing CM17A support in HA directly (with the switch interface only initially and ignoring lamp support)
  6. Something else?

Is there anyone else interested in X10? Apologies for the dumb questions.

1 Like

I went with #4 above, project is hosted https://github.com/clach04/x10_rest and seems to be working for me at the moment.

One thing that took me a little time was working out how to have multiple rest switches, is that worth updating the docs for rest.switch with an example? It would have saved me some time as I initially cloned the switch section and then had duplicate definition errors.

Not really…the layout of the configuration.yaml file is covered extensively in the documentation.

Just for anyone else who has the cm19a, I’m using mochad plus mochad_dispatch to enable X10 sensors. Otherwise I am using a cmdline to send commands to the X10 devices.

I ended up reading up the (builtin) MQTT support in HA last night after I’d implemented the rest interface. Having built in MQTT support is certainly compelling.

Interesting that mochad_dispatch is a one-way bridge, and doesn’t send to mochad. @texnofobix did you look into adding send-command support to mochad_dispatch or are you happy with shelling to cmdline?

Any other secret x10 users lurking? :wink:

I only have 3 x10 switchable devices. I agree the two way mode would be cool. I used to interface x10 with pytomation and then attached it to HA.

I just hacked in (undocumented and I’m not 100% happy with it) Mochad support to https://github.com/clach04/x10_rest, if https://github.com/jpardobl/hautomation_x10 is available it will use it and connect to the local Mochad server. It only treats it like a switch and the status support is essentially not there. I don’t have a cm19/15 device so this has NOT been tested with a real Mochad server (just my fake one).

If your system is working for you, don’t touch it :smile:

1 Like

Nice rest api! When I get a chance, I will try it out. The cm19a only sends rf so I might make it send over both pl and rf. :slight_smile:

So it turns out there are no complete/working Python clients to Mochad :frowning: I started to attempt to patch one but it needed a lot of work

I just hacked in rf support to x10_rest, I really should implement a config option but for now the current code should work as a stop-gap.

I have experience with mochad as part of the pytomation project. We might be able to reuse some of that logic.

Good idea, https://github.com/zonyl/pytomation/blob/master/pytomation/interfaces/mochad.py does look like it could be used as the basis for a new standalone module.

I query mochad for status like this:

- platform: command_line
   switches:
     some_lamp:
       oncmd: "/home/hass/X10cmd rf a3 on"
       offcmd: "/home/hass/X10cmd rf a3 off"
       statecmd: "/home/hass/X10cmd st | /bin/grep -oP '3=\\K.*'"
       value_template: '{{ value == "1" }}'
2 Likes

I threw together an x10 package which is available on PyPi (ergo pip). x10_rest has been updated to make use of it.

I spent today hacking together a custom x10 component available at https://github.com/clach04/home-assistant-x10

Its limited to sending on/off (and that’s it). For my use case (well the hardware I have) that is good enough.

1 Like

Had a bug report, looks like this currently requires Python 3.5.1 as mochad support doesn’t work with Python 3.4 (potential fix is up on github but pip install won’t pick that up yet).

This looks cool. I have an old X10 installation that uses a Comfort controller. I’m looking to replace that with HA. I did get as far as hooking up the old serial X10 interface to my Pi, via a USB adaptor, and used shell calls to heyu to turn lights on and off. I’ll give this a try.

The other thing I need to is to hook up the existing PIRs to the Pi. I’m just wary of blowing it up :slight_smile:

That would be great, it would be nice to get more hardware tested/supported.

I have limited hardware access, I only have a Firecracker. Someone with a real Mochad server has reported some oddities with delays for the library I’m using for talking to Mochad (https://github.com/clach04/x10_any/issues/1) which we’re working on right now, the more help we can get with debugging the faster this will be solved :slight_smile:

New fixes posted, older versions of Python along with real Mochad servers now work.

HA x10 support updated to handle whole house code sends of all-lamps-on and all-off.

I hooked up an Amazon Dash button to all-off :slight_smile:

https://home-assistant.io/blog/2016/07/30/custom-frontend-panels-jupyter-notebooks-directv/ mentioned x10 support (https://home-assistant.io/components/light.x10/) this requires Heyu and so has limited platform/hardware support. However as this is now part of upstream it may be easier to patch in support for other platforms/devices?

I’ve only quickly skimmed the code, it looks like they show up as lights only, and dimming is not supported. I suspect you can use a regular switch module but it will show up as a light which is a little odd.

Dumb question; where does development discussion take place? I don’t have time to review all pull requests. I thought by joining and posting here I’d get to see x10 development discussions but the 0.25 release post was the first I heard about this.

1 Like