Using Homebridge on the Raspberry Pi

In this tutorial, you will be learning how to set up the Homebridge software on the Raspberry Pi.

Raspberry Pi Homebridge

Homebridge is a lightweight NodeJS server that is built to emulate the iOS HomeKit API.

Using this software, you can integrate various aspects of your home with Apple Home.

You can also make use of Homebridge to connect various 3rd party apps that aren’t normally supported by Apple Home.

For example, you can install a plugin that allows you to control a Mi Air Purifier, a device that doesn’t have Apple Home support out of the box.

Being a lightweight server means it is perfect for your Raspberry Pi as it won’t drain all of the Pi’s limited processing power.

Equipment List

Below is a list of the equipment that you will need to set up the Homebridge software on the Raspberry Pi

Recommended

Raspberry Pi 1, 2, 3 or 4

Micro SD Card

Power Supply

Ethernet Cord or WiFi dongle (The Pi 3 and 4 has WiFi inbuilt)

Optional

Raspberry Pi Case

For this tutorial, we were running the latest available version of Raspbian Buster running on a Raspberry Pi 4.

Preparing your Raspberry Pi for Homebridge

In this section, we will be preparing your Raspberry Pi for Homebridge by installing Node.js to the Raspberry Pi.

The Homebridge server is built off of the Node.js runtime.

1. The first task is to add the official Node.js repository to our package list.

Doing this will allow us to install more up to date versions of the server software than what is available in the default Raspbian repository.

curl -sL https://deb.nodesource.com/setup_12.x | sudo bash -

This command will pipe the bash script from the Node Source website to bash. You can verify the content of this script by going directly to it in a web browser.

2. Let’s now install node.js, Python as well as the GCCcompiler to our Raspberry Pi.

Run the following command to install these packages.

sudo apt install -y nodejs gcc g++ make python

3. Verify that nodejs has been installed by running the following command.

node -v

This command will return the current version of the NodeJS software if it has been installed correctly.

4. Now let’s ensure that the version of npm is the latest available by running the command below.

sudo npm install -g npm

npm is a package manager for NodsJS modules and is what we will use to install the Homebridge software.

Installing Homebridge on your Raspberry Pi

With NodeJS and npm installed to our Raspberry Pi, we can go ahead and use them to install Homebridge.

1. Run the following command to install Homebridge and the Homebridge Config UI X modules on your Raspberry Pi.

sudo npm install -g --unsafe-perm homebridge homebridge-config-ui-x

We will be installing Homebridge Config UI X alongside Homebridge as it gives us an easy to use web-based management tool for the Homebridge software.

2. To get the Homebridge software to start up at boot, we can go ahead and run the following command.

sudo hb-service install --user homebridge

This command will use the provided hb-service tool to setup and install Homebridge as a service.

Accessing Homebridge Config UI X

1. To access the web interface, we will need to know the IP address of our Raspberry Pi.

You can get the local IP address of your Raspberry Pi by running the following command.

hostname -I

2. In your favorite web browser, go to the following address.

Make sure that you replace “[RASPBERRYPIIPADDRESS]” with the IP address you retrieved in the previous step.

http://[RASPBERRYPIIPADDRESS]:8581

3. The following login screen will now greet you.

To login to the Homebridge software, you can use the default username, admin, and the default password, admin.

Raspberry Pi Homebridge Login Interface

You can change the default username and password within the Homebridge web interface.

4. You should now have access to your Raspberry Pi’s Homebridge web interface.

This web interface will show you several pieces of information, including the code you need to use to connect the Homebridge software to the Apple Home software.

Homebridge Dashboard on Raspberry Pi

Within this web interface, you can install, remove, and update plugins while also giving you the ability to modify the Homebridge configuration. You will quickly find that the UI makes dealing with Homebridge a breeze.

Uninstalling Homebridge

If at any time, you have decided you no longer want to make use of the Homebridge software on your Pi, you can uninstall it by following the steps below.

1. First we need to remove the Homebridge service by running the command below.

sudo hb-service uninstall

2. Next, we need to uninstall the homebridge and the homebridge-config-ui-x packages.

We can uninstall these packages by making use of npm.

sudo npm uninstall -g homebridge homebridge-config-ui-x

Hopefully, at this point, you will now have successfully set up the Homebridge software on your Raspberry Pi.

If you have run into any issues in connecting your Raspberry Pi to Apple Home, feel free to drop a comment below.

Leave a Reply

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