
This guide, adapted from oznu’s Homebridge Config UI X Wiki, will show you how to set up multiple instances of Homebridge and Homebridge Config UI X using systemd on a Raspberry Pi. This guide assumes you already have a Pi set up and running a recent version of Raspbian.
- Step 1: Assume root
- Step 2: Install Node.js and Other Dependencies
- Step 3: Install Homebridge and Config UI X
- Step 4: Create User for Homebridge Service
- Step 5: Create Storage Directory for Homebridge
- Step 6: Create Default config.json
- Step 7: Create systemd Service Templates
- Step 8: Activate the New Services
- Step 9: Manage and Configure Homebridge
Multiple instance support is now depreciated (since Homebridge v1.3.0 or later), use Child Bridges instead.
Homebridge now supports Child Bridges which are an easier to manage alternative to running multiple instances. This feature allows any Homebridge platform or accessory to optionally run as its own independent accessory, separate from the main bridge, and in an isolated process.
Step 1: Assume root
1 | sudo su - |
All the steps in this guide assume you are running as the root user:
Step 2: Install Node.js and Other Dependencies
Install the LTS version of Node.js from the official repository, as well as additional dependencies:
1 | curl -sL https://deb.nodesource.com/setup_14.x | bash - |
The installation of Node.js on arm32v6 devices such as the Raspberry Pi 1 and Raspberry Pi Zero is not supported by the official repository using the steps above. Instead use the following commands to install Node.js.
1 | # update repos and install deps |
Step 3: Install Homebridge and Config UI X
Now install Homebridge and Homebridge Config UI X:
1 | npm install -g --unsafe-perm homebridge@latest homebridge-config-ui-x@latest |
Step 4: Create User for Homebridge Service
This is the user Homebridge will run under.
1 | useradd -m --system homebridge |
This user will require password-less sudo permissions. To safely update your /etc/sudoers file, run this command:
1 | echo 'homebridge ALL=(ALL) NOPASSWD: ALL' | sudo EDITOR='tee -a' visudo |
Step 5: Create Storage Directory for Homebridge
This is where Homebridge will store its configuration and cache. Other plugins may also use this directory to store persistent data.
1 | mkdir -p /var/lib/homebridge@1 |
For more than one instance of Homebridge, create additional directories as needed:
1 | mkdir -p /var/lib/homebridge@2 |
Step 6: Create Default config.json
Use the following command to create the default config.json file:
Copy and paste this entire block into the terminal as one command!
1 | cat > /var/lib/homebridge@1/config.json << EOL |
For more than one instance of Homebridge, copy this config.json to /var/lib/homebridge@2/config.json, /var/lib/homebridge@3/config.json, etc.
Important: For each of these, you must change some values to be different:
- Under
"bridge":-
"name" -
"username" -
"port" -
"pin"
-
- Under the
"Config"platform:-
"port"(e.g.,8081) -
"restart"(e.g.,"sudo -n systemctl restart homebridge@2") - Under
"log":-
"service"(e.g.,"homebridge@2")
-
-
Example configuration file for 2nd instance of Homebridge.
1 | cat > /var/lib/homebridge@2/config.json << EOL |
Example configuration file for 3rd instance of Homebridge.
1 | cat > /var/lib/homebridge@3/config.json << EOL |
Step 7: Create systemd Service Templates
Use the following command to create the systemd service template homebridge@.service:
Copy and paste this entire block into the terminal as one command!
1 | cat > /etc/systemd/system/homebridge@.service << EOL |
Use the following command to create the systemd service template homebridge-config-ui-x@.service:
Copy and paste this entire block into the terminal as one command!
1 | cat > /etc/systemd/system/homebridge-config-ui-x@.service << EOL |
Use the following command to create the service defaults file:
Copy and paste this entire block into the terminal as one command!
1 | cat > /etc/default/homebridge << EOL |
Optional: You may create additional default files customized to each instance of Homebridge. First, copy /etc/defaults/homebridge into /etc/defaults/homebridge@1, /etc/defaults/homebridge@2, etc., and then edit them to suit your needs. This is useful, for example, to enable debug logging for a certain instance.
Step 8: Activate the New Services
This will ensure Homebridge starts on boot:
1 | systemctl daemon-reload |
If you are creating multiple instances, list them alongside the first.
- Example of activating 2 Homebridge instances.
1 | systemctl daemon-reload |
- Example of activating 3 Homebridge instances.
1 | systemctl daemon-reload |
Step 9: Manage and Configure Homebridge
To manage Homebridge, go to http://<ip of server>:<port of instance> in your browser. For example, go to [http://192.168.1.20:8080](http://192.168.1.20:8080/), [http://192.168.1.20:8081](http://192.168.1.20:8081/), etc., depending on which instance you want to manage. From here you can install, remove, and update plugins; modify the Homebridge config.json; and restart Homebridge.
The default username is admin with password admin. Remember you will need to restart Homebridge to apply any changes you make to the config.json.
The Homebridge logs can be viewed using the web interface, but if you need to view them via the terminal, run this:
1 | sudo journalctl -f -u homebridge@1 |
To view the logs of other instances, just change the index:
1 | sudo journalctl -f -u homebridge@2 |
