X10 Community Forum

💬General Category => Mac/Linux & Open Source and the X10 Home => Raspberry Pi, Arduino & other SBC => Topic started by: petera on August 01, 2018, 03:57:04 PM

Title: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: petera on August 01, 2018, 03:57:04 PM
For anyone wanting to try X10 on the Raspberry Pi using the Home Assistant platform the following steps should get you there. Maybe the mods could add it as a sticky. I'll gladly answer any questions but purely on topic.

Just to recap on the installation instructions and the creation of a homeassistant service. I'ts all in the one place now for others to follow.

Assuming Home Assistant is where it should be on the Raspberry Pi the instructions below for creating the service should work.

1. You will need a fresh copy of Raspbian Stretch Lite (not the desktop version) written to an SD card. Details to achieve this here https://hackernoon.com/raspberry-pi-headless-install-462ccabd75d0

2. Now that your Raspberry Pi setup and have SSH into it from another computer you will see the a prompt. Now its time to install Heyu on the Raspberry PI. Follow these instructions exactly as they are presented in this link. NOTE when you get to the section where it asks you who you want this to be available to select option 3 and NOT 1 as mentioned in the instructions https://blog.wouterspaans.nl/2017/02/23/control-your-x10-lights-from-a-raspberry-pi/

3. Now it's time to install Home Assistant. This is the manual install which is what you need here
https://www.home-assistant.io/docs/installation/raspberry-pi/

4. Now that you have Home Assistant up and running you need to configure it to run X10. The following link will demonstrate how to configure it by editing what is called the configuration.yaml
https://www.home-assistant.io/components/light.x10/


Creating the Home Assistant service as follows

Step 1 sudo nano /etc/systemd/system/homeassistant.service

It opens the editor so paste this text exactly as I've supplied it


[Unit]
Description=Home Assistant
After=network-online.target

[Service]
Type=simple
User=%i
ExecStart=/srv/homeassistant/bin/hass -c "/home/homeassistant/.homeassistant"

[Install]
WantedBy=multi-user.target

Step 2 Once you have pasted this text press ctrl-x  then press y and press the return key.

Step 3 Now at the command prompt type sudo systemctl enable homeassistant.service and press the return key

Step 4 Now type sudo systemctl start homeassistant.service and press the return key.

If everything went well you should be able to access HA on the browser without your SSH session being opened.

Every time you restart the Raspberry Pi HA will start automatically.

If your homeassistant.service is not running type sudo systemctl status homeassistant.service and it will tell you what the status of the service is.

If you find that the blue sliders on your X10 lights are not turning from blue to yellow and will not turn off your lights you need to setup a service to run Heyu on start up. Just copy and paste the following at the Terminal/Command prompt.

Here's a heyu.service file based on the install instructions I supplied.

sudo nano /etc/systemd/homeassistant.service

Now copy and past this text into the editor and press ctrl x then press y When you have finished type sudo systemctl enable heyu.service followed by sudo systemctl start heyu.service. That should sort out the Heyu service not working properly

[Unit]
Description=Heyu Engine
Wants=network.target
After=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/home/pi/heyu-2.10
ExecStart=/usr/local/bin/heyu engine

[Install]
WantedBy=multi-user.target

You now need to modify the homeassistant.service to delay the startup of Home Assistant while Heyu starts first.

This is the modified homeassistant.service file with the extra line added to allow heyu start before home assistant

[Unit]
Description=Home Assistant
After=network-online.target

[Service]
ExecStartPre=/bin/sleep 20
Type=simple
User=%i
ExecStart=/srv/homeassistant/bin/hass -c "/home/homeassistant/.homeassistant"

[Install]
WantedBy=multi-user.target

Don't forget to stop your service file before you edit them.

These two files will get heyu running first and then launch Home Assistant all at boot time

Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: Tuicemen on August 01, 2018, 04:29:33 PM
For anyone wanting to try X10 on the Raspberry Pi using the Home Assistant platform the following steps should get you there. Maybe the mods could add it as a sticky.
Done!

Many users are contemplating using the Zero W this doesn't have a ethernet port so you must use WI-Fi
Am I wrong in thinking the wi-fi is disabled on the pi until you configure it?
Also many old time Windows users like my self love the Desktop environment and are just more comfortable even if it is just displaying in the background.
Since it is possible to disable the Desktop environment after install (as well as other things) can the setup not be done on the full Debian installer? This would make it much easier for newbies as finding setup and configurations of the pi are easier Desktop.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: petera on August 01, 2018, 07:08:36 PM
For anyone wanting to try X10 on the Raspberry Pi using the Home Assistant platform the following steps should get you there. Maybe the mods could add it as a sticky.
Done!

Many users are contemplating using the Zero W this doesn't have a ethernet port so you must use WI-Fi
Am I wrong in thinking the wi-fi is disabled on the pi until you configure it?
Also many old time Windows users like my self love the Desktop environment and are just more comfortable even if it is just displaying in the background.
Since it is possible to disable the Desktop environment after install (as well as other things) can the setup not be done on the full Debian installer? This would make it much easier for newbies as finding setup and configurations of the pi are easier Desktop.

This link shows you how to setup your Raspberry Zero W for wifi without the need to use a GUI. You just follow the instructions, pop your SD card into your Pi, power it up and your good to go.
https://www.raspberrypi-spy.co.uk/2017/04/manually-setting-up-pi-wifi-using-wpa_supplicant-conf/

Of course you can use a full desktop version of Raspbian OS with Home Assistant called Pixel. Very basic but it allows you the GUI look and feel. It does however use valuable resources and is not necessary to run Home Assistant. You can as you say disable it using the sudo raspi-config from the Terminal.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: Tuicemen on August 01, 2018, 07:16:52 PM
Thanks, both options newbies should find useful. I didn't realize you could setup your Wi-fi prior to booting. A very good tip! :)%
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: petera on August 01, 2018, 08:10:31 PM
Thanks, both options newbies should find useful. I didn't realize you could setup your Wi-fi prior to booting. A very good tip! :)%

Yes the lack of an Ethernet port on the Zero W prompted this solution. The Zero is effectively for embedded solutions so using a GUI would probably defeat the purpose. Works nicely with a standard Pi too. Really does make it plug'n'go unit once the OS is installed using this method.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: Tuicemen on August 21, 2018, 12:24:14 PM
@petera
Since many here use either the CM15 or Cm19 in their setups I would assume step two in your OP should be replaced with a mochad install?
Maybe step two should be broken down to if using these transceivers install this.
Or is heyu still required regardless? I assume it isn't.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: petera on August 21, 2018, 01:07:49 PM
@petera
Since many here use either the CM15 or Cm19 in their setups I would assume step two in your OP should be replaced with a mochad install?
Maybe step two should be broken down to if using these transceivers install this.
Or is heyu still required regardless? I assume it isn't.

No it's Heyu CM11/CM17 or Mochad CM15.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: Tuicemen on August 22, 2018, 06:55:57 PM
OK I have mochad installed and the service running ha installed and service running :)%
I can open the HA web page :)%
Now what most here will what to know.
How do I setup HA to control X10 modules on the CM15A? :o
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: lviper on August 23, 2018, 09:17:16 AM
Now what most here will what to know.
How do I setup HA to control X10 modules on the CM15A? :o

Edit your configuration.yaml and add the following:

Code: [Select]
mochad:
  host: localhost
  port: 1099

light:
  - platform: mochad
    devices:
      - address: a1
      - address: a5

Change the address to your device.
You can also add a name to the device. If memory serves me, using the above example.

Code: [Select]
mochad:
  host: localhost
  port: 1099

light:
  - platform: mochad
    devices:
      - address: a1
        name: a1 device name
      - address: a5
        name: a5 device name

When editing yaml files pay attention to the spacing.
The following WILL NOT work

Code: [Select]
mochad:
host: localhost
port: 1099

light:
- platform: mochad
devices:
- address: a1

Once you have your config completed you have to restart HA. The best way to do this is to open the HA frontend web page, click on Configuration on the left, then General. Click Check Config to make sure you don't have any errors in your configuration.yaml, then click Restart under Server Management. You will get a message saying something failed, just ignore it and click back to Overview. In a minute you will see a list of your x10 lights with lightening bolts for on and off. That's all you get in HA since mochad does not offer any state information.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: lviper on August 23, 2018, 09:31:37 AM
I forgot to add to my last. Use switch if you want to define your device as a switch.

Code: [Select]
switch:
  - platform: mochad
    devices:
      - address: a1
        name: my wall switch

Also remember, while mochad will see your palmpad and turn on your light, HA won't. It will still show off in HA. To turn off a light in HA that is currently on you will need to turn it on then off.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: Tuicemen on August 23, 2018, 09:55:52 AM
I seen in the Mochad documentation to add this to the yam file but how do I find it?
whats the Path? I don't see where you can do it from the UI.
Also remember, while mochad will see your palmpad and turn on your light, HA won't. It will still show off in HA. To turn off a light in HA that is currently on you will need to turn it on then off.
Well that just sucks!
HG will see commands from a palm pad and reflect it in the UI. as well it will see security RF.
I can see this isn't the software for me, but since I've got it loaded I'll play a bit. ;)
The average long time AHP user won't do all this coding to get something that only half works with their X10. It is a shame there are lots of protocol options in HA
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: bkenobi on August 23, 2018, 12:22:27 PM
Also remember, while mochad will see your palmpad and turn on your light, HA won't. It will still show off in HA. To turn off a light in HA that is currently on you will need to turn it on then off.
Are you saying that HA can't see incoming RF commands and act on them?  That can't be right since motion sensors send an RF command which many people use as triggers for other things.  The most basic config is to set a module to the same HU code as the motion sensor, but I certainly don't think that should be considered the only approach.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: Tuicemen on August 23, 2018, 12:59:03 PM
Ok found the configuration.yaml file located here: homeassistant@raspberrypi:~/.homeassistant $ For those as lost as I am.

Now where do I add the mochad lines? ::) :'
all documentation just says add to the file. No location  :-[ beginning, end, under some special heading B:( B:(
I'm beginning t believe this is a total waste of my time, ::) :'
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: petera on August 23, 2018, 01:17:10 PM
Ok found the configuration.yaml file located here: homeassistant@raspberrypi:~/.homeassistant $ For those as lost as I am.

Now where do I add the mochad lines? ::) :'
all documentation just says add to the file. No location  :-[ beginning, end, under some special heading B:( B:(
I'm beginning t believe this is a total waste of my time, ::) :'

Try reading up a little more on the configuration of Home Assistant before trying to configure it. This link will give you a little more insight into adding the Mochad service assuming the service is physically on the same Pi https://www.home-assistant.io/components/light.mochad/
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: petera on August 23, 2018, 01:30:23 PM
Does this link explain things a little clearer https://community.home-assistant.io/t/mochad-configuration/48649

The community forum has nearly all the answers you require.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: Tuicemen on August 23, 2018, 01:34:33 PM
Mochad is on the same PI.
That link tells me nothing! What lviper posted tells me more then that either link which by the way I've already read  as well as the switch and component instructions (more then once).
If this is what it takes to get X10 working in HA, guessing at locations then I'm out.
Read this read that! I just want to test the dam thing! If I decide I like it then I'll read more.

 Installation should be the hardest thing about this not configuring it. B:( B:(

Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: lviper on August 23, 2018, 01:38:44 PM
Also remember, while mochad will see your palmpad and turn on your light, HA won't. It will still show off in HA. To turn off a light in HA that is currently on you will need to turn it on then off.
Are you saying that HA can't see incoming RF commands and act on them?  That can't be right since motion sensors send an RF command which many people use as triggers for other things.  The most basic config is to set a module to the same HU code as the motion sensor, but I certainly don't think that should be considered the only approach.

No, HA does not see the RF signals directly. This was my whole problem when trying to figure my current solution and why I didn't use mochad. THere is a mochad_dispatch that will publish security rf to HA using MQTT, but it doesn't support regular rf.

I'm using Heyu with the CM11a and a W800USB from WGL Design for wireless. Once everything is setup in Heyu and working, I publish my MS16 motion and DS10a security sensors to HA using MQTT. Sounds more difficult then it actually is.

In theory if you had both a CM11a and CM15a you could achieve what I have. But you would have to use both mochad and Heyu. Let mochad and CM15 forward rf to plc. Then let heyu and the cm11 pickup the plc and act on it using Heyu scripts to publish to HA using mqtt.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: lviper on August 23, 2018, 01:43:38 PM

Now where do I add the mochad lines? ::) :'

At the end of the file is fine. You can add a comment line also which is what I did.

example:
Code: [Select]
# mochad x10 configuration
mochad:
  host: localhost
  port: 1099

light:
  - platform: mochad
    devices:
      - address: a1
        name: a1 device name
      - address: a5
        name: a5 device name
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: petera on August 23, 2018, 01:51:06 PM
Mochad is on the same PI.
That link tells me nothing! What lviper posted tells me more then that either link which by the way I've already read  as well as the switch and component instructions (more then once).
If this is what it takes to get X10 working in HA, guessing at locations then I'm out.
Read this read that! I just want to test the dam thing! If I decide I like it then I'll read more.

 Installation should be the hardest thing about this not configuring it. B:( B:(

Iviper managed to setup X10 with Mochad using Home Assistant on the Raspberry Pi.

I'm finding the more help I'm offering the more temperatures are rising so I'm backing away from the X10 forum for the moment. I just suggested reading up a little more on the platform but as you say you just want to get it going.

Good luck with your exploits if you choose to persevere.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: lviper on August 23, 2018, 02:18:51 PM
If this is what it takes to get X10 working in HA, guessing at locations then I'm out.
Read this read that! I just want to test the dam thing! If I decide I like it then I'll read more.

 Installation should be the hardest thing about this not configuring it. B:( B:(

I learned quickly that HA IS NOT a "point and click to setup and configure platform." There is a lot of configuration file editing going on. I think that's what adds to the power of HA allowing for extremely indepth settings that aren't limited by a GUI.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: Tuicemen on August 23, 2018, 03:11:45 PM
tempers aren't rising just frustration with not getting a simple answer like, Where in the configuration file does my Mochad X10 entry need to be?
I know what they should look like! and thats all the documentation I've found states. If it doesn't mater that's fine, but if I put it where it is required and it doesn't work I know a setting is off and I can debug.
If it has to be before groups or in groups thats what I need to know.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: lviper on August 23, 2018, 03:24:13 PM
tempers aren't rising just frustration with not getting a simple answer like, Where in the configuration file does my Mochad X10 entry need to be?
I know what they should look like! and thats all the documentation I've found states. If it doesn't mater that's fine, but if I put it where it is required and it doesn't work I know a setting is off and I can debug.
If it has to be before groups or in groups thats what I need to know.

Did you see my reply a few posts back? It really doesn't matter where in the configuration.yaml file you put the mochad stuff. I usually just put my new stuff at the end.

Only time when it matters is for example when using light:. You can't have 2 sections that start with light. Example.

This is wrong
Code: [Select]
light:
  - platform: mochad
    devices:
    - address: a1

light:
  - platform: x10
    devices:
    - id: a2

It should be like this:
Code: [Select]
light:
  - platform: mochad
    devices:
    - address: a1

  - platform: x10
    devices:
    - id: a2

2 different platforms using light devices.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: Tuicemen on August 23, 2018, 04:59:05 PM

Now where do I add the mochad lines? ::) :'

At the end of the file is fine. You can add a comment line also which is what I did.

example:
Code: [Select]
# mochad x10 configuration
mochad:
  host: localhost
  port: 1099

light:
  - platform: mochad
    devices:
      - address: a1
        name: a1 device name
      - address: a5
        name: a5 device name
Thanks I'll attempt this If I can remember how to get back to the configuration file.
I know I don't have it entered at the end of the file.
One more question once this info is entered in the configuration file what can I expect to see in the UI? that will help me determine if the setting is right,  sometimes you just luck out other times your pulling hair and mine currently is to short to get a hold of. rofl
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: lviper on August 23, 2018, 05:16:19 PM
Thanks I'll attempt this If I can remember how to get back to the configuration file.
I know I don't have it entered at the end of the file.
One more question once this info is entered in the configuration file what can I expect to see in the UI? that will help me determine if the setting is right,  sometimes you just luck out other times your pulling hair and mine currently is to short to get a hold of. rofl

Once you log in to the Rpi I just type in the following to get to my configuration file. I'm sure there's a easier faster way but it works for me.
Code: [Select]
cd /home/homeassistant/.homeassistant
To edit the file I do this.
Code: [Select]
sudo nano configuration.yaml
The code doesn't have to be at the end, I just keep adding new stuff to the end to make it easier. But you do have to enter different platform information under the same device type as I mentioned above.

Once you have the configs entered and you saved your file, you need to restart HA either from the command line or from the web interface (aka frontend). Then you should see a card called Lights with each of your x10 devices listed. You'll have a different card if you used switch. Each device will have 2 lightening bolts to the right, one for on and one for off.

Here is a pic of one of my cards. Where mine says Other Lights you should have Lights. Where the sliders to the right are in mine you will have the 2 lightening bolts.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: Tuicemen on August 23, 2018, 05:40:44 PM
Success! :)%
I see modules but only my switches respond I suspect it is how I have them entered as I see the address uses caps B:(
I'm not sure if it was the location of the entry or the IP change form local host to the actual IP, but at least I'm getting somewhere. ::) :'
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: lviper on August 23, 2018, 06:12:45 PM
Success! :)%
I see modules but only my switches respond I suspect it is how I have them entered as I see the address uses caps B:(
I'm not sure if it was the location of the entry or the IP change form local host to the actual IP, but at least I'm getting somewhere. ::) :'

It was probably the ip instead of localhost. I think I had the same problem.
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: Tuicemen on August 23, 2018, 06:23:49 PM
Yes did some experimenting  the actual IP works as does 127.0.0.1 but not localhost.
The killer for this is HA doesn't report PLC or RF received events so devices never change status unless controlled from the interface. Not sure I could live with that. there must be a work around. ::) :'
Title: Re: Home Assistant and X10 on the Raspberrry Pi-Installation instructions (Revision)
Post by: lviper on August 24, 2018, 08:54:50 AM
Yes did some experimenting  the actual IP works as does 127.0.0.1 but not localhost.
The killer for this is HA doesn't report PLC or RF received events so devices never change status unless controlled from the interface. Not sure I could live with that. there must be a work around. ::) :'

You just experienced the main reason I didn't go this route.

If you have a CM11 I believe there may be a way. A hack of a way and not really ideal, but in theory it should work.

Use the cm15 with mochad. Let mochad forward your rf to plc. Then the cm11 and heyu can pick up on that. The cm11 and heyu will update the status in HA.

So for example. Say you have a light on A1. You would have mochad forward your A1 rf to the powerline. Heyu would see it and know A1 was turned on. Then HA would know it was turned on from heyu's state engine.

Basically use the cm11a and mochad as I use my w800usb. You should also be able to use mochad with mochad_dispatch to act on the security rf. Of course this is all theory from my experience of what I have tried and where I ended up.