Adding X10 support

Could you expand on how you hooked up your Amazon Dash button?
Thanks!

Iā€™ve a couple of blog posts on it:

But the TL;DR is:

  • POST an event using the HA REST-API, the Dash MAC is used as part of the event name (it could be a pay load, I choose not to do that for reasonsā€¦)
  • have custom rule for the event

I have one all-off button and another that toggles a specific light on/off.

The REST interface that HA offers is really great.

Happy to answer questions.

1 Like

Just found this discussion after having traveled a similar road!

I played around with the new X10 support from 0.25 and found it didnā€™t behave consistently enough for my tastes. In addition, I started getting a lot of errors from it polling heyu when enabled. I ended up turning it off and going about it a different way.

My use case doesnā€™t call for many X10 lights, but I make extensive use of the older MS13a motion sensors. Heyu supports running scripts on x10 events, so I set up heyu to make a call to a script that sends x10 state information to HA as an http binary sensor. It certainly isnā€™t the fastest or most efficient way to accomplish what Iā€™m doing, but it does work, and the delay is < 1 second in most cases, which is acceptable. The MS13a also has dark/light detection, which I utilize the same way. Here is a sample configuration if anyone could use a hand:

(I should mention, Iā€™m receiving x10 RF information from a W800RF32, which is supported natively in heyu - but any RF receiver with heyu support should work similarly)

example from heyu x10config:
ALIAS LivingRoom B2 MS13a RFFORWARD SCRIPT B2 on anysrc :: /home/pi/bin/heyu_to_ha B 2 ON LivingRoom_Motion SCRIPT B2 off anysrc :: /home/pi/bin/heyu_to_ha B 2 OFF LivingRoom_Still SCRIPT B3 on anysrc :: /home/pi/bin/heyu_to_ha B 3 ON LivingRoom_Dark SCRIPT B3 off anysrc :: /home/pi/bin/heyu_to_ha B 3 OFF LivingRoom_Light
heyu_to_ha:
#!/bin/sh curl -X POST -H "x-ha-access: APIKEY" -H "Content-Type: application/json" -d '{"state": "'$3'", "attributes": {"friendly_name": "'$4'"}}' http://localhost:8123/api/states/binary_sensor.$1$2
Then I just have automations in HA that trigger on state change of the motion sensor:

- alias: Motion in LivingRoom
  trigger:
    platform: state
    entity_id: binary_sensor.b2
    state: "ON"
  condition:
  - condition: state
    entity_id: binary_sensor.b3
    state: "off"
    condition: state
    entity_id: input_boolean.lock_livingroom
    state: "off"
  - condition: state
    entity_id: group.all_devices
    state: "home"
  action:
    service: homeassistant.turn_on
    entity_id: script.motion_livingroom

script.motion_livingroom just turns on the light and starts a timer to turn it off if it isnā€™t locked on.

This all works fine. I have about 20 of these units in various places around my home, and they trigger pretty often. Both heyu and HASS seem to keep up fine. The lights arenā€™t yet 100% reliable, but theyā€™re pretty close and get better as I figure out the edge cases.

You can likewise use HAā€™s command_line switches to have heyu toggle x10 lights. I tested this, but donā€™t use it in my configuration, so I have no examples.

I am open to suggestion if there are better ways, but this works if anyone needs x10 motion sensor support.

1 Like

I already have a cm11 with working lights/switches but recently added on onto a different branch of power in my home. The cm11 doesnā€™t see it but I was able to add a cm17 and control it directly via the heyu command line. Is there a way to integrate the cm17 into HASS with my already working cm11?

What does your existing setup look like? Is it already integrated with HA?

The now built into HA x10 component https://home-assistant.io/components/light.x10/ uses Heyu so that may be your quickest path as you mention you have that working.

Iā€™m using https://github.com/clach04/home-assistant-x10 successfully with my cm17 under Windows (works under Linux too).

Yes, already using HA with a CM11A & Wink & Echo. Current code for X10:

light:

  • platform: x10
    lights:
    • name: Living Room Lamp
      id: A2
    • name: Table Lamp
      id: A3
    • name: Display Lamp
      id: A9
    • name: Hall Lights
      id: A5
    • name: Back Porch
      id: A16
    • name: Front Porch
      id: B15
    • name: Kitchen Lights
      id: C13

The C13 is not working through HA but I can use Heyu from the command line. I was wondering if there was a way to integrate the firecracker directly into HA as well to control the other leg/branch of power. I have looked over the previous posts but am still new to HA and donā€™t really understand the MQTT. Is that how it is done? Maybe I should just get something that is compatible with the HUE or Wink but Iā€™d rather use the X10 I already own

If C13 is not working that sounds like a bug in the official x10 support. Iā€™d recommend opening a ticket in github (or start a new thread).

Youā€™re welcome to try using https://github.com/clach04/home-assistant-x10 which wouldnā€™t require Heyu setup but youā€™d loose out on status information if the lights are changed outside of HA. Or you could spawn the command line tool using your own config like Zenā€™s

For fear of stating the obvious (and apologies if you have already checked) - If everything is working fine except for a single house code / unit combination, I would advise double checking the setting on the module. (or test that it works with a power line controller plugged in nearby on the wire). Also, (again, apologies if you have already checked, just brainstorming) if you have a large house, itā€™s possible that signals wont make it all the way down the line. Especially if they have to jump phases. Try that same module in the place of one that is currently working (or just swap their codes, if they are wired in) and test again. I had this problem in my home, and added a phase coupler/repeater to my dryer plug to fix it.

@Corey_Johnson - re-read your post and just thought of something else - Have you configured your firecracker in heyu? It works a little differently than the cm11a does. Check out the man page ā€˜x10cm17aā€™ for more information. Hope that helps!

I did put a firecracker in-line and was able to command it via the prompt. I have not figured out how to control it via HASS. Is this something I need to do via x10config? I read the file so I understand the commands are somewhat different. At this point I am thinking I should just drop a few more Cree bulbs and retire some of the x10. Thank you for your help!

Iā€™m using the X10 component that comes with HA. It works, but I canā€™t seem to switch a light off from the switch I get on the web. I can in automation or using the voice control. Dimming would be good as Iā€™d like my landing light to come on at a lower level during the night. Iā€™ll see if I can understand the code some time. Iā€™ve only just set it all up, so still testing, but for just turning lights on and off it seems to be fine.

Confusingly, the x10 component I created https://github.com/clach04/home-assistant-x10 is not the one that ships with HA, even though it was published earlier.

https://github.com/clach04/home-assistant-x10 definitely works with the web interface at least with 0.27.x, Iā€™ve not yet had chance to upgrade to 0.32. It uses switches but the underlying x10 control library can be used for dimming so that would require some work.

I believe Heyu supports dimming which is what the component that ships with HA uses. So if Heyu is working for you, hacking the official one is probably going to be the quickest path for you. If you want to take a look at the portable (runs everywhere including Windows) component that doesnā€™t require Heyu and add dimming, Iā€™d be interested in Pull Requests :wink:

If I install your component will it clash with the included one as they seem to have the same name? I had to install Heyu to get this far, but it is pretty much working. Iā€™m not against doing some testing for you if I can find the time.

No clash, they have the same (end) name but the name space is different.

I canā€™t edit the original post so posting current status here.

Iā€™m using https://github.com/clach04/home-assistant-x10 with HA 0.33.0 every day with a Firecracker serial device https://www.x10.com/cm17a.html (over USB with a usb2serial adapter) on a Windows machine.

Whilst I do not use https://sourceforge.net/projects/mochad/ Iā€™ve had a report that this works with Mochad (on a Raspberry Pi).

Posted Dimming control over X10 lights/lamps - it should avoid needing to read through the whole thread for anyone interested in x10 support without heyu.

This is really cool. Can you tell me what the ā€˜X10cmdā€™ is? Is this a script you wrote or a binary? Can you share?

X10cmd is just a shell script:

#!/bin/sh

echo "$@" | nc localhost 1099

I donā€™t use it anymore because Iā€™ve switched to using the mochad component, but here is an updated example:

some_lamp:
  oncmd: "/home/hass/X10cmd rf a4 on"
  offcmd: "/home/hass/X10cmd rf a4 off"
  statecmd: "/home/hass/X10cmd st | /bin/sed -n 's/.*4=\\([0-1]\\).*/\\1/p'"
  value_template: '{{ value == "1" }}'
1 Like

i notice there is statecmd in this script for X10
i check this "statecmd: ā€œ/home/hass/X10cmd st | /bin/sed -n ā€˜s/.4=\([0-1]\)./`/pā€™ā€
but seems not working.
iā€™m trying to implement X10 motion sensor like MS10A X10 module,
but not sure whether possible?

The example is using A4 as the house code, so the ā€œ4ā€ in the regex would need be changed to match the code of your device. I donā€™t use X10 motion sensors, but I believe they are listed as security devices in the status output. Iā€™m not sure if the status differs enough to require more changes. Perhaps you could post the output after triggering your device?