1. Getting Linux installed on your Raspberry Pi
Download Raspbian: https://www.raspberrypi.org/downloads/raspbian/
Write image to SD card (instructions: https://www.raspberrypi.org/documentation/installation/installing-images/README.md)
Put the SD card in the Raspberry Pi and let it boot up
Figure out what IP adress the Raspberry Pi has been assigned, either through your router or by running arp -a to show all devices on your network.
Connect to the RPi via SSH:
Default username: pi
Default password: raspberry
ssh pi@<ip address>
“The authenticity of host ‘10.0.1.124 (10.0.1.124)’ can’t be established.” – type yes and press enter. This is just a warning to make sure you’re not connecting to an unknown server.
Congratulations, you are now logged in to your RPi.
Now expand the file system to fill the entire SD card (and make space for our Homebridge installation). Run raspi-config and select the option to expand the file system.
Then reboot the system and reconnect once it’s back online:
- wait for half a minute or so -
ssh pi@<ip address>
2 Installing NodeJS
First, find the latest (or preferred) version of NodeJS on their website (or in https://nodejs.org/dist/ ). If you have a Raspberry Pi 1 you will need the file with armv6l in it’s name, and the Pi 2 will need the armv7l one.
At the time of writing this, the LTS version is 4.2.6 – the version I’ll be using for this guide.
Once you have the url to the correct file, run the following command to download it to you Pi:
Unpack the file with the following command:
tar -xvf node-v4.2.6-linux-armv7l.tar.gz
Enter the node-v4.2.6-linux-armv7l directory and copy it’s contents to
/usr/local: sudo cp -R * /usr/local/
That’s it, NodeJS is now installed on your Raspberry Pi. You can verifiy this by running node -v, which should return v4.2.6 (or whatever version you downloaded):
3. Installing Homebridge
Before installing Homebridge, you need to make sure you have libavahi-compat-libdnssd-dev installed:
sudo apt-get install libavahi-compat-libdnssd-dev.
Also, we will need Git:
sudo apt-get install git
We can now install homebridge:
npm install -g homebridge
You should now be able to run homebridge, which will fail with a few errors.
4. Configuring Homebridge
First of all, we will need a configuration file. Create one using the following command:
Paste this example content into the file, and change values accordingly:
"name": "My Homebridge Name",
"description": "My Homebridge description here",
Save the file and try starting Homebridge by running the command homebridge. It should start and your PIN-code should be visible. You should also be able to find your homebridge in the HomeKit app of choice (iDevices and Eve are fairly good, free apps).
5. Adding plugins
Now we’re ready to start adding plugins to get some actual functionality. Plugins are installed through npm:
npm install -g homebridge-http
When the installation has finished, edit the accessories-portion of your config.json to look like this (obviously with your own addresses):
"name": "Doomsday device",
"username" : "",
"password" : ""
Save the file and run Homebridge again. You should now see it initialize your newly added accessory. Start your Homekit-app and try to add a new product – it should show up.
6. Starting Homebridge automatically at system start
First we need to create an init script, and for the sake of getting things done – copy this script to your clipboard: https://raw.githubusercontent.com/fhd/init-script-template/master/template
Create and edit a new init script, and paste the contents on your clipboard in it:
sudo nano /etc/init.d/homebridge
Change the first lines of the files to this:
### BEGIN INIT INFO
# Provides: homebridge
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
Now change the permissions for the file and “install” it:
sudo chmod 755 /etc/init.d/homebridge
sudo update-rc.d homebridge defaults
Homebridge will now launch on reboot, and you can manually start it with this command:
sudo /etc/init.d/homebridge start
Run this command to verify that homebridge starts as expected, and to see any errors. The command will show the last 30 entries from the system log:
tail -n 30 /var/log/syslog
At the time of writing this guide there are issues with Hombridge failing within minutes or hours from startup, a restart of homebridge seems to solve this until a fix is issued:
sudo /etc/init.d/homebridge restart