X10 Community Forum

💬General Category => Mac/Linux & Open Source and the X10 Home => Raspberry Pi, Arduino & other SBC => Topic started by: Tuicemen on August 18, 2018, 02:49:55 PM

Title: Pi newbie HA-Bridge Guide
Post by: Tuicemen on August 18, 2018, 02:49:55 PM
COs, Please don't post to this thread unless it is to add info for this setup.
Setting up The Ha-Bridge on a Pi is straight forward and should be as simple on any SBC running Linux for the Experienced PI user, just follow the directions posted in the HA-Bridge readme:
For the absolute PI Beginner the instructions may look a bit confusing (they did to me ay first too)
For this reason I'll do a step by step
This assumes you have no other server running using port 80 as HA-bridge initially starts using that port. If so change the port in the other servers before you start!
1: in your PI open a terminal window (this is Basicaly a command prompt)
2: copy or type below into the terminal and hit enter (this makes the ha-bridge folder)
Code: [Select]
mkdir ha-bridge3: copy or type below into the terminal and hit enter (this moves you into the ha-bridge folder)so the program can be placed there.
Code: [Select]
cd ha-bridge4:copy or type below into the terminal and hit enter( this downloads the required file.
Code: [Select]
wget https://github.com/bwssytems/ha-bridge/releases/download/v5.2.1/ha-bridge-5.2.1.jar5:copy or type  below  and hit enter(this changes the name to just ha-bridge.jar it helps with updates )
Code: [Select]
mv ha-bridge-5.2.1.jar ha-bridge.jar6: if you plan to run as a service (meaning you want this to run on every boot up) then
copy or type below and hit enter( this moves you to the folder where services are handled
Now to create the HA-Bridge service:
Code: [Select]
cd /etc/systemd/system7: copy or type and hit enter (this opens a text editor to create the HA-Bridge service.)
Code: [Select]
sudo nano ha-bridge.service8: with the nano text editor screen open, copy or type exactly the below text into the new screen
Code: [Select]
Description=HA Bridge


ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/ha-bridge/data/habridge.config /home/pi/ha-bridge/ha-bridge.jar

Save the file in the editor by hitting CTL-X and then saying Y to update and save. Hit Enter  and this should close the nano window and return you to the terminal window to enter more commands
9:type or copy below and hit enter (this reloads all service files, ha-bridge.service included so the Pi knows they are here)
Code: [Select]
sudo systemctl daemon-reload10: copy or type below and hit enter (this loads the service and starts HA-Bridge)
Code: [Select]
sudo systemctl start ha-bridge.service
Now we want to load the service so it starts for every boot
11: copy or type below and hit enter ( this tells the pi to run HA-Bridge at every start up)
Code: [Select]
sudo systemctl enable ha-bridge.service
If all of the above seems to much then you can just use the installer I created.

Once you have ha-bridge installed and running open your web browser on your Pi to localhost. Once HA-Bridge is displaying click on the Bridge Control tab.
If you wish to change your port scroll down to Web Server Port and edit the 80 to what ever port you wish to use,  See attached.

If you have a Broadlink RM continue to scroll down until you see Broadlink Support. click the false button so it turn to true.
If you have any other things (hubs or software) supported by the bridge set their info as well then scroll to the top and click save.
When the bridge restarts you'll be at the Devices screen go back to the Bridge control tab (screen) and click Update Security Settings
This will allow you to setup users and password so access to the bridge so it is restricted to only those users you wish access.
I'll post how to add devices in this thread in another post.
Title: Re: Pi newbie HA-Bridge Guide
Post by: Tuicemen on August 18, 2018, 02:51:10 PM
Setting up HG controlled X10 devices in HA-Bridge
Depending on what HA software your running on your Pi will affect  what your on/off/dim commands will be
for HomeGenie which I currently have running here are some popular ones:
1- on command is: http:// your Home genie IP & Port/api/HomeAutomation.X10/A3/Control.On
2- off the command is http:// your Home genie IP & Port/api/HomeAutomation.X10/A3/Control.Off
3- AllLightsOn is http:// your Home genie IP & Port/api/HomeAutomation.X10/A/Control.AllLightsOn
4- AllLightsOff is http:// your Home genie IP & Port /api/HomeAutomation.X10/A/Control.AllLightsOff
5- one step Dim http:// your Home genie IP & Port/api/HomeAutomation.X10/<module_address>/Control.Dim

Setting up Mochad to call X10 devices in HA-Bridge

This assume you have made the script file called X10cmd and placed it in the ha-bridge folder
1- on command is: ./x10cmd pl a1 on
2- off the command is: ./x10cmd pl a1 off
3- AllLightsOn is ./x10cmd pl a all_lights_on
4- AllLightsOff is: ./x10cmd pl a all_lights_off
5- One step Dim is: ./x10cmd pl a1 dim
Title: Re: Pi newbie HA-Bridge Guide
Post by: Tuicemen on August 18, 2018, 02:53:46 PM
Adding devices to HA-Bridge
From the ha-bridge interface click on add/edit and enter your device info.
Note: you must click the add button to the right of the on/off or dim items lines prior to scrolling to the top and clicking Add Bridge Device attched is a screen shot for my x10 Wolf Lamp controlled by HG. You may need to download and enlarge it to see all details
To control devices with mochad the entries are a bit different as we'll be using a script not sending a http call
Adding Broadlink RM devices is a bit different as are other devices you may be controlling from other software or hubs.
Title: Re: Pi newbie HA-Bridge Guide
Post by: Tuicemen on August 20, 2018, 02:52:20 PM

Setting up HA-Bridge for sending calls to mochad!
mochad can be setup a couple of different ways depending on if it is on the same pi or on another device.
Here I'll be assuming your using the x10cmd script  and a copy of it is in the ha-bridge folder.
As with the HG setup you need to navigate to the Add/Edit tab  attached is a sample of my same wolf lamp configured to use Mochad you may need to download it(recommended) to see all details
Title: Re: Pi newbie HA-Bridge Guide
Post by: Tuicemen on August 24, 2018, 01:35:07 PM

I've split and removed comments to a separate thread ( http://forums.x10.com/index.php?topic=30444.30 ) to make any additions easier to find. If you wish to comment or need help please start a new thread or post to the above linked thread.
COs, Please don't post to this thread unless it is to add info for a setup.