0%

How to install homebridge on raspberry

First Step

Buy a Raspberry Pi

Actually the link explains everything. I will note that something important and explain how to figure out some tricky problems.

Please following the steps.

Install GCC 7

1
2
3
4
5
6
7
git clone https://bitbucket.org/sol_prog/raspberry-pi-gcc-binary.git
cd raspberry-pi-gcc-binary
tar xf gcc-7.2.0.tar.bz2
sudo mv gcc-7.2.0 /usr/local
export PATH=/usr/local/gcc-7.2.0/bin:$PATH
echo 'export PATH=/usr/local/gcc-7.2.0/bin:$PATH' >> .bashrc
source .bashrc

Install Node

1
2
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Install Avahi and other Dependencies

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

Install Homebridge

1
sudo npm install -g homebridge

Use the following commaned if you got the permission problem.

1
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/5.5.0"
1
2
sudo npm install -g --unsafe-perm homebridge
homebridge

Figure out some problems

You got the error message if you runs the homebridge command. I have a tricky solution. Please following the steps.

1
2
3
sudo rm -rf /usr/lib/node_modules/
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Set up the configure and name /home/pi/.homebridge/config.json

1
2
3
4
5
6
7
8
{
"bridge": {
"name": "Homebridge",
"username": "FF:FF:FF:FF:FF:FF", // MAC address of Ethernet on Raspberry
"port": 51826,
"pin": "111-11-111" // Set up what you want to
},
}

Set up boot up

  • To save the following words and to name homebridge into /etc/default
1
2
3
4
5
6
7
# Defaults / Configuration options for homebridge
# The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pairing and others)
HOMEBRIDGE_OPTS=-U /var/lib/homebridge

# If you uncomment the following line, homebridge will log more
# You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*
  • To save the following words and to name homebridge.service into /etc/systemd/system/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[Unit]
Description=Node.js HomeKit Server
After=syslog.target network-online.target

[Service]
Type=simple
User=homebridge
EnvironmentFile=/etc/default/homebridge
# Adapt this to your specific setup (could be /usr/bin/homebridge)
# See comments below for more information
ExecStart=/usr/local/bin/homebridge $HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target
  • Configuration
1
2
3
4
5
6
7
8
sudo useradd --system homebridge
sudo mkdir /var/lib/homebridge
sudo cp /home/pi/.homebridge/config.json /var/lib/homebridge/config.json
sudo chown -R homebridge:homebridge /var/lib/homebridge/
sudo systemctl daemon-reload
sudo systemctl enable homebridge
sudo systemctl start homebridge
journalctl -u homebridge

Open your Homekit on your iPhone or iPad

  • Import the homebridge into your Homekit

Plugins

  • homebridge-server
    MUST install the plugin that will helpful to install other plugins and management your homebridge
1
sudo npm install homebridge-server@latest -g

Add this snippet to your config.json:

1
2
3
4
5
6
7
{
"platform": "Server",
"port" : 8765,
"name" : "Homebridge Server",
"log" : "/var/log/homebridge-server.log",
"restart" : ""
}

Restart your service and open your browser http://raspberry-ip:8765

1
sudo systemctl restart homebridge

How to remote control the Homekit

Please set up Home Hub in your iPad

Enjoy your Smart Home