Skip to main content

Running ha-bridge inside LibreELEC on your Pi2/3…yes, really!

This is huge! Thanks to aptalca for creating an arm based Docker container for the Raspberry Pi (and Odroid C2!) that allows ha-bridge to run inside the LibreELEC Docker add-on!

First thing you need to do is ensure your Raspberry Pi LibreELEC has a static IP address so you always know how to get to the ha-bridge web interface.
  • Kodi > Programs > LibreELEC configuration > Connections then select your active connection (LAN or Wi-Fi) and use the context menu to select ‘Edit’.
  • Scroll to IPV4 and change your IP address settings so they are static by using the Manual settings. Of course, you could always create a DHCP lease in your router if you are savvy with that and that is the better way to go.
If you have more than one media player, I recommended settings them with static IP’s next to each other like xxx.xxx.xxx.201, xxx.xxx.xxx.202 etc. In that way, (if you use Android) you can use the excellent SSH Button app by David Grootendorst to create buttons to easily reboot Kodi from your phone or tablet if Kodi ever hangs. Sadly, I have not found a IOS app that’s as nice.

Second thing you need to do (IMPORTANT) is change the web server port that Kodi is using as the default is port 80 which ha-bridge needs to use in order to be compatible with Google Home.
  • Kodi > Settings > Services > Control > Web server and change the port to 8080 (or whatever you like) as long as it’s not 80.
Now you can go ahead and get the Docker add-on for LibreELEC made by the devs at LE.
  • Kodi > Add-ons > Install from repository > LibreELEC Add-ons > Services > Docker
  • Once installed, use the context menu to edit the settings in Docker if you want Kodi to pop-up notifications when your Docker container starts, stops or otherwise farts. Docker > Settings > Notifications. Either select ‘All’ or ‘Custom’.
Now you’re ready to bring down the Docker image file for ha-bridge and start the container.
  • Login to your Raspberry Pi (root:libreelec) and run the following command.
  • docker run -d --name="habridge" --restart=always --net="host" -e SERVERIP="your-pi’s-ip-address" -e SERVERPORT="80" -v /storage/downloads/habridge:/config:rw -v /etc/localtime:/etc/localtime:ro aptalca/home-automation-bridge-arm
    • Replace “your-pi’s-ip-address with the static IP address of your Pi (do not use localhost as this will prevent ha-bridge from ‘seeing’ devices on your network).
    • Replace the "/path/to/config" with your choice of location. For LibreELEC, the path must start with /storage as that is the only location that is writeable.
    • If the -v /etc/localtime:/etc/localtime:ro mapping causes issues, you can try -e TZ="<timezone>" with the timezone in the format of "America/New_York" instead. Get your time zone here http://www.timezoneconverter.com/cgi-bin/zoneinfo.
  • It will take about 5 mins for your  Raspberry Pi to download, extract and install the required components.

    image
  • After the installation is finished, the ha-bridge container should be running. Test this using docker ps -a. This will list the running containers showing you the container ID and name (habridge).
  • Open a browser and navigate to the IP address of your Pi. You should now see the ha-bridge web interface. If you see the Kodi interface, you did not change the Kodi web server port at the start of this guide. Go back and do that then refresh the web page.
Full and comprehensive instructions on configuring ha-bridge are on the GitHub repository https://github.com/aptalca/docker-ha-bridge. Mad props to BWS Systems, the creators of ha-bridge. It really brings your Amazon Echo or Google Home to life. Additional info on the ha-bridge docker image is on the GitHub repository https://github.com/aptalca/docker-ha-bridge (DO NOT use the instructions on the GitHub repository to download and start your container as those instructions are for x86 based processors).
Some Docker commands for controlling your ha-bridge container
  • docker ps -a (list all running containers so you can copy the container ID for use in the next commands)
  • docker stop <container ID> or <container name> (e.g. docker stop habridge)
  • docker start <container ID> or <container name>
  • docker restart <container ID> or <container name> (restarts the container downloading the latest ha-bridge build if necessary)
  • docker stats <Container ID> (Show statistics including CPU use. Control + C to exit)
  • docker logs <Container ID> (Hopefully you’ve already tried this, but if not, start here. This’ll give you the full STDOUT and STDERR from the command that was run initially in your container).
  • docker cp <Container ID>:/path/to/useful/file /local-pathOften just getting hold of more log files is enough to sort you out. If you already know what you want, docker cp has your back. Copy any file from any container back out onto your local machine, so you can examine it in depth.
  • docker rm <container ID> (removes the container. Stop it first)
  • docker rmi aptalca/home-automation-bridge-arm (removes the complete docker image file). Simply use the ‘docker run -d…’ command above to re-download the image and start a new container.
  • Additional info about removing Images and Containers can be found here https://tecadmin.net/remove-docker-images-and-containers/

Comments

Popular posts from this blog

Using ESPEasy with Home Assistant via MQTT

Preface: I've just started playing around with Home Assistant on a Raspberry Pi and exploring the world of MQTT to control devices on the network. Learning curve is a bit steep but worth the effort as MQTT is very fast. The hardware and software tools I'm using are as follows: 2 x Sonoff relay units 2 x NodeMCU Boards ESPEasy firmware (must be version 121 or above as that contains the MQTT 'retain' flag option. Home Assistant software on Raspberry Pi2 MQTT Test Software: PC: MQTT.fx Android: MQTT Dashboard

My Notepad++ tricks when editing YAML files in Home Assistant

To comment out a whole section in one go: Highlight the text you want to comment out and use CTRL + Q. If you do this at the start of a line, it will only comment that line. CTRL + Q is toggle mode (comment on/off). CTRL + K will allow you to add multiple comments one after the other.

How to check what entities are filling up your Home Assistant database

If you use the Home Assistant MariaDB add-on, this tip will show you how to query the database so see what Home Assistant entity states are triggering the most, filling up your database. What were going to do: Install the phMyAdmin add-on for MariaDB. Query the MariaDB database. See what entity state changes have the most action. Paste the code below into the SQL query box:  select entity_id,count( * ) from states group by entity_id order by count ( * ) desc; And if you're using the internal home-assistant_v2.db instead, you can use the SQLite Web add-on to achieve the same thing.