Phone, Tablet & Desktop HA-Bridge control

This is a PHP control interface to use with BWSSystems’ ha-bridge. It uses the ha-bridge’s device output and state engine to create a device control interface for all configured ha-bridge devices. The code employs twitter bootstrap for mobile compatibility and fluidity.

If you want to control X10 devices with the ha-bridge, you’ll need to follow my Amazon Echo X10 Home Control guide.

 

 

NOTE: If you use the ha-bridge, I urge you to Donate to BWS Systems (Donate link at bottom), the ha-bridge is distributed freely and continuously updated.

For the ha-bridge control interface, do the following:

Prerequisite components

  • Linux box, preferably a Raspberry Pi
  • Apache
  • PHP5
  • @bwssytems ha-bridge >= v1.1.0

Installation

  1. On an updated functioning Linux box install Apache and PHP5:
    $ sudo apt-get install apache2 -y
    $ sudo apt-get install php5 libapache2-mod-php5 -y
  2. The ha-bridge now uses port 80 by default, so we need to change Apache’s default port:
    $ sudo nano /etc/apache2/ports.conf

    • change Listen 80 to Listen 8080
    • save and exit, CTRL + X follow save prompt
    • Restart Apache $ sudo /etc/init.d/apache2 reload
  3. Download, configure and run the ha-bridge as per @bwssystems’ README
  4. Install in an empty directory:
    $ cd /var/www/html/
    $ ls -l
    Be sure to remove all files listed using the following command structure
    $ sudo rm index.html
    Now clone the control code to your Raspberry Pi
    $ sudo git clone https://github.com/audiofreak9/HA-Bridge_Control .
  5. Set up and configuration:
    $ cd includes
    $ sudo nano config.php

    • The DEFAULT ha-bridge IP is set to auto-detect $SN = "localhost";. Otherwise set according to your ha-bridge installation IP if on another machine, example: $SN = "192.168.1.2";
    • The DEFAULT ha-bridge port is 80, set according to your ha-bridge installation port
    • The DEFAULT username is ‘username’, set according to your HA Bridge username (if set) -OR- your preference
    • The DEFAULT password is ‘password’, set according to your HA Bridge password (if set) -OR- your preference

Usage

In any browser on your device of choice (Phone, Tablet & Desktop):

  • http://<HOST IP>:8080
  • Items with DIM ability have a slider to select DIM level
  • The “Power” icon buttons operate the device
  • The “Wrench” icon buttons update the device’s state in the ha-bridge

TIP: You can save the page to your homescreen on mobile devices and it will function like an app.

31 thoughts on “Phone, Tablet & Desktop HA-Bridge control

  1. Sorry, one more question, does the php control part have to be on the same physical network as the HA-Bridge? My Raspberry PI is not, currently, exposed to the Internet, but I have another Linux server that is.

    1. The PHP has to be able to reach the HA-Bridge by IP or name on the same network to get the configured devices and send commands. It is coded with localhost since I run it on the same machine, but you can change the “$SN” variable in the config.php file.

      Look at item 5 on my github for this project here: https://github.com/audiofreak9/HA-Bridge_Control.

  2. Corey,

    I have HA-Bridge working to control my X10 devices from Amazon Echo and have installed the php interface. It loads on both my iphone and laptop via the chrome browser and appears to be running but the commands are not sent to hardware. If I use the HA-Bridge web interface, everything works, the php interface sees the two devices and changes the dim slider control but the hardware does not switch. Any suggestions on ways to troubleshoot?

    1. I’d start by editing the config.php file, changing the line with $SN = "localhost"; to be the IP of the device where the ha-bridge is running instead. So it would be something like $SN = "192.168.1.2";, but with your IP instead.

  3. I’m sure it is obvious to those familiar with Linux, but you might want to add “$ cd HA-Bridge_Control” at the start of #5

      1. I got it working, but not perfect. After i complete the log in correctly i am sent to xxx.xxx.xxx.xxx/8080/, the “Debian Logo Apache2 Debian Default Page” (index.html) instead of xxx.xxx.xxx.xxx/8080/control/index.php. If i manually type that it in i get the correct page. (Which is really cool by the way!!) , but i’m not sure what i did wrong other than the initial error above..

        1. That is actually my fault, in the PHP code. I personally run the control page in the root html folder.

          To clone from github on linux, the folder you clone to must be empty. It was easier to have users create a new empty folder then have them remove any files in the root html folder, especially if they have webpages already created.

          To fix the issue edit the login.php file, do the following:
          $ cd
          $ cd /var/www/html/control
          $ sudo nano login.php
          change line 13 from
          header(‘Location: /’);
          to
          header(‘Location: /control’);
          then hit ‘CTRL + X’, follow the prompts to save the file.

          You will now be properly directed to the control page after the login.

          I also updated my github file, so you could also re-clone the project if you wish, instead of editing the file.

            1. Thanks, I’ve got an improved version coming once ver 4.0.0 of the ha-bridge is released, it’s currently in beta.

          1. I’m also working on a python script that runs in a cron job to update your X10 device states on the ha-bridge to keep it accurate, since X10 equipment can be scheduled by the CM11A or controlled with remotes, etc. independent of the ha-bridge.

  4. I get a Notice: undefined index: deviceState in index.php line 41. Any idea how to fix?

    1. Al,

      What version of the ha-bridge are you running?
      Do you have any non device heyu commands configured? Like heyu upload, heyu setclock or heyu engine, etc?
      Do you have any multi X10 module devices configured?

      My PHP script as posted to github currently does not handle multiple devices well – errors. I have a new version ready for ha-bridge 4.0.0 to be released, which is in beta testing now.

    2. Al,

      Until I release my new version, here is what you can do:
      $ cd
      $ cd /var/www/html
      $ sudo nano index.php
      Find Line 41 which contains:
      $dev_level = round(($ha_devices[$x]["deviceState"]["bri"] / 255)*100);
      and replace it with:
      $dev_level = (is_numeric($ha_devices[$x]["deviceState"]["bri"])) ? round(($ha_devices[$x]["deviceState"]["bri"] / 255)*100) : 0;
      then hit “CTRL + X”, follow prompts to save. Now try the control page again.

      I updated my github this way as well.

  5. Corey,
    FYI, I have the HA-bridge with your HA bridge control running on a windows PC using the Abyss web server and it works great! I am controlling x10 devices both with Ha-bridge control and with the Echo Dot. Thanks for this great program!

      1. Corey,
        Any chance you could update HA-Bridge control to work with bridge v4.3.1 ? I am trying to use Alex10 with Alexa and that is using this version.

        Al

        1. I have it working with v4.3.1, but I’ll take a look at the code. I may need your config file for testing, I’ll let you know.

          1. Thanks . I am running it under windows. It recognizes the bridge devices but does not control them. And does not indicate any error. It worked great with v3.5.1 of bridge on the same pc.

          2. Ok, great thanks for the extra information, that gives me a place to focus. Let me see what changed from v3.5.1 to v4.3.1 to troubleshoot. I’ll let you know…

          3. BTW, I may take our conversation to email, OK if I contact you using your gmail?

        2. Ok, I did find that the code needed to be tweaked on my GitHub repository. You can re-install the HA-Bridge Control files following my original tutorial. You can remove the current files first, although you may want to note your configuration in the config.php file.

Leave a Reply

Your email address will not be published. Required fields are marked *