All about Homebridge, drive your smarthome from iOS [Exclusive Guide]

3:05 pm November 8, 201611352

Homebridge is year Open Source project developed by Nick Farina ( Github , website ). It is a modular project which can add plugins depending on the material you want to add to the iPhone (or iPad). There are already more than 260 plugins ( the list complete here ) and you can even expand your ( examples to start ).

You have plugins for leading home automation software (Domoticz, Wizard, OpenHAB, Jeedom, FHEM… Home) and for many Devices (bulbs Philips Hue , Synology NAS…).

Let’s start with updating the system

 sudo apt - get update sudo apt - get upgrade 

If your distribution does not support the automatic expansion of the partition (at first launch, it is for example the case for Domoticz image), run raspi-config.

 sudo raspi-config 

Go to Option 1 – Expand Filesystem . Then Finish and finally Allow reboot .

once re-connected, we can install homebridge

 npm set prefix '/ usr' g g homebridge update sudo sudo - unsafe-perm 

Find the Mac address of your Raspberry PI. It is unrated but without this configuration (trick found here ), you may not be able to detect the HB bridge on iPhone (or iPad).

Run ifconfig . The Mac address of the RPI is HWaddr right . [

hombridge domoticz adresse mac rpi hwaddr

open the configuration file in a text editor (pico or nano)

 sudo nano ~/.homebridge/config.json

Change the value of the key username Mac using the address of your PII. You can assign a personal Pin code. Save (Ctrl + X) then O (or Y). The following example is taken from the Setup for Domoticz tutorial . You will need to adjust the plugin you need.

homebrige domoticz edomoticz config
Example of configuration of Homebridge for Domoticz.

Launch HB manually with the command homebridge .

homebrige domoticz premier demarrage
At startup, home automation devices are presented to iOS

At startup, HB search all devices configured and makes them visible by year iPhone gold year iPad connected to the local network.

At he moment, “hot Exchange” are not able. We need to restart manually whenever you add material a Homebridge. This is so a few useful commands.

Check first of all that the sources of HB have been installed globally. [

 sudo npm install g homebridge 

Then it publishes the init.d file

 sudo nano etc/init.d/homebridge

Copy this code in the file ( original source code ).

 #! / bin/sh # 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 dir = "/ home/IP" cmd ="DEBUG = * / usr/local/bin/homebridge" user = "pi" name = 'basename $0' pid_file="/var/run/$" stdout_log="/var/log/$name.log" stderr_log="/var/log/$name.err" get_pid() {cat "$pid_file"} is_running() {[ -f "$pid_file" ] & 'get_pid' ps >/dev/null 2 > & 1} "$1" box in start) if is_running; then echo "Already started" else echo "Starting $name" cd "$dir" if [ -z "$user" ]; then sudo $cmd > "$stdout_log" 2 > "$stderr_log" & else sudo u "$user" $cmd > "$stdout_log" 2 > "$stderr_log" & fi echo $! > "$pid_file" if! is_running; then echo "Unable to start, see $stdout_log and $stderr_log" exit 1 fi fi;
stop) if is_running; echo-n "Stopping $name.." then kill 'get_pid' for i in {1.10} do if! is_running; then break fi echo-n "." sleep 1 done echo if is_running; then echo "Not stopped;" "may still be shutting down or shutdown may have failed" exit 1 else echo "Stopped" if [ -f "$pid_file" ]; then "$pid_file" fi rm fi else echo "Not running" fi;
restart) $0 stop if is_running; then echo "Unable to stop, will not attempt to start" exit 1 fi $0 start;
status) if is_running; then echo "Running" else echo "Stopped" exit 1 fi;
*) echo "use: $0 {start | stop | restart | status}" exit 1;

We need to make the script executable

 sudo chmod 755 etc/init.d/homebridge

And now we ask the OS to start the script at startup

 sudo update - rc.d homebridge defaults 

You can run it manually with the command

 sudo /etc/init.d/homebridge start 

If HB is already running the script will inform you and will do nothing more.

Other useful commands for fly Homebridge


To manually stop

 sudo /etc/init.d/homebridge stop 

Know the State

Run the following command to see if the service is started or stopped.

 sudo /etc/init.d/homebridge status 


You come to make a change in the configuration file ~/.homebridge/config.json, run the option restart to revive.

 sudo /etc/init.d/homebridge restart 

Once HB is configured to start at boot, we have more visual feedback of what’s happening. Here are two other very useful commands to access logs in real time. [[

 tail-f var/log/homebridge.log

And look at the log of errors

 tail-f var/log/homebridge.err