Skip to content

Running Homebridge on a Raspberry Pi

Henning Hontheim edited this page Jul 20, 2018 · 20 revisions

If you are new to Raspberry Pi / Raspbian, please first read the documentation here.

Basic setup

Log in as pi [ not root! ]

Unsure?

whoami
sudo apt-get update
sudo apt-get upgrade

How do I know which version I'm running?

uname -a

Wheezy or Jessie?

lsb_release -a

Install Node

Check gcc version (4.8 is required)

gcc --version
gcc (Raspbian 4.8.2-21~rpi3rpi1) 4.8.2

Install gcc 4.8 if necessary

sudo apt-get install gcc-4.8 g++-4.8

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50

Reboot the Raspberry Pi.

Raspberry Pi 2 Model B

Via sources

wget https://nodejs.org/dist/v4.2.1/node-v4.2.1-linux-armv7l.tar.gz 
tar -xvf node-v4.2.1-linux-armv7l.tar.gz 
cd node-v4.2.1-linux-armv7l
sudo cp -R * /usr/local/

or via package manager as root from official repo

sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install --yes nodejs

Raspberry Pi Model B, B+

wget https://nodejs.org/dist/v4.2.1/node-v4.2.1-linux-armv6l.tar.gz 
tar -xvf node-v4.2.1-linux-armv6l.tar.gz 
cd node-v4.2.1-linux-armv6l
sudo cp -R * /usr/local/

To check Node.js is properly install and you have the right version, run the command:

node -v

Install Avahi

This is required by the mdns package in HAP-NodeJS library.

sudo apt-get install libavahi-compat-libdnssd-dev

Install homebridge

sudo npm install -g homebridge --unsafe-perm 

Install homebridge-punt

sudo npm install -g homebridge-punt

Configuration

Add the punt-platform in config.json in your home directory inside .homebridge.

{
  "bridge": {
    "name": "Homebridge",
    "username": "CC:22:3D:E3:CE:30",
    "port": 51826,
    "pin": "031-45-154"
  },
  
  "platforms": [
    {
      "platform" : "punt",
      "name" : "punt"
    }
  ],           

  "accessories": []
}

Add config-punt.json into your directory .homebridge/plugins/homebridge-punt.

Test Homebridge

Deactivate the gateway ("run": false) in config-punt.json in order to test the installation without connecting to the Fhem-Server.

  "gateway": {
    "name": "fhem",
    "url": "127.0.0.1",
    "port": "8083",
    "auth": {"user": "foo", "password": "bar"},
    "run": false,
    "longpoll": true
  },

start homebridge

homebridge

stop homebridge

ctrl+c

Use Homebridge

Define config-punt.json for your Application.

Validate your config-punt.json here

Updates

Node/npm Update

sudo npm cache clean -f
sudo npm install -g n
sudo n latest
sudo npm install -g npm

Homebridge Update

sudo npm update -g homebridge

Homebridge-punt Update

sudo npm update -g homebridge-punt

Troubleshooting

FAQ: The Homekit app (e.g. EVE) doesn't find Homebridge.

Tip: Install avahi-utlis

sudo apt-get install avahi-utils

run

avahi-browse -t _hap._tcp
+  wlan0 IPv6 Homebridge       _hap._tcp         local
+  wlan0 IPv4 Homebridge       _hap._tcp         local

Tip: Install Discovery - Bonjour Browser on your iOS device.

Run Discovery and see if HAP (_hap._tcp) shows up.

Homebridge not displayed? There might be an issue with your LAN/WLAN Layout. Try a simple Layout without Switches/Repeaters. A Wifi adapter instead of the Ethernet cable might help.

Note: If using a WiFi adapter, disable the WiFi power management. Example for the Realtek 8192CU chipset:

echo "options 8192cu rtw_power_mgnt=0 rtw_enusbss=0" | sudo tee --append /etc/modprobe.d/8192cu.conf

Tip: Change config.json

    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 51826,
        "pin": "031-45-154"
    },

to another name and username

    "bridge": {
        "name": "Homebridge-02",
        "username": "CC:22:3D:E3:CE:31",
        "port": 51826,
        "pin": "031-45-154"
    },

and run homebridge again.

EVE will find the new Homebridge-02.

FAQ: Server error: Error: listen EADDRINUSE

Tip: Change the port number in config.json

    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 51926,
        "pin": "031-45-154"
    },

No solution found? Open a new issue with the specifications about your RPi:

uname -a
gcc --version
ERR! messages
...

References

Clone this wiki locally
You can’t perform that action at this time.