Hi,

Over Christmas I did a proof of concept and install Homebridge on a Debian virtual machine. That worked well and so bit the bullet and bought a Raspberry Pi 2 Model B. I thought you might like to see what I had to do to make it work. If you find any issues with this, let me know and I will try and clarify.

Best wishes

Michael

This assumes you have got past the Noobs setup.

I used these links to as a basic for my install

http://www.automatedhome.co.uk/apple...mart-home.html

https://gist.github.com/johannrichar...feb6adb9eb61a/

My Raspberry Pi 2 is cabled and not using Wifi. I also gave the Raspberry Pi 2 a static ip address.

I ran the commands below to get the latest updates.

sudo apt-get update
sudo apt-get upgrade


Next I installed Node. Do this as Root.

sudo su

Type whoami to find out which user you are - you should be root

I checked my Node version before I installed it with the command

node -v

It returned

v0.10.29

I ran the command below to install Node

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

apt-get install --yes nodejs


I reran - node –v and got version v5.3.0

Type Exit to get out of root

Type whoami to find out which user you are - you should be your default user

Homebridge wouldn’t install without me installing the below.

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

Install Homebridge

sudo npm install -g homebridge

Next install plugins. For me I installed the below.

sudo npm install -g homebridge-wemo

If you now run Homebridge you will get an error message about no config file being found.

Make the config file

cd ~/.homebridge/

Make config file - I changed the username and pin. I just changed some of the characters, but kept the format. This is a default config from the Homebridge website

{
"bridge": {
"name": "Homebridge",
"username": "CC:22:3D:E3:CE:30",
"port": 51826,
"pin": "031-45-154"
},

"description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.",

"accessories": [
{
"accessory": "WeMo",
"name": "Coffee Maker"
}
],

"platforms": [
{
"platform" : "PhilipsHue",
"name" : "Hue"
}
]
}

Type nano config.json – This will make the file in the ~/.homebridge folder. You can copy and paste the config straight into this file, but be careful it pastes correctly.

You can test the file has been saved with - cat ~/.homebridge/config.json

I would copy the output and paste it to this site. http://jsonlint.com. It will validate the configuration. If it fails, check the quotes are correct and look out for added spaces. You don’t want to see curly quotas. They should be straight.

Type Homebridge and it should start. You can use the command

ps -aux | grep [h]omebridge from another terminal session to check Homebridge is running.

The [h] - stops the command itself from showing up in the result

As it stands if you reboot the Raspberry Pi 2 , Homebridge won’t restart. To make Homebridge start on reboot do the following. I changed the instructions slightly by making the user homebridge_user. These instructions are based on these instructions - https://gist.github.com/johannrichar...feb6adb9eb61a/


Make a new user - sudo useradd --system homebridge_user
Make this folder - sudo mkdir /var/homebridge

Now set up the permissions for the above folder

sudo groupadd homebridge_group
sudo usermod -a -G homebridge_group homebridge_user
sudo usermod -a -G homebridge_group pi


You can check users were added to the new group - grep homebridge_group /etc/group
I’ve added the pi user and the homebridge_user

sudo chown -R :homebridge_group /var/homebridge
sudo chmod -R g+rwX /var/homebridge
sudo chmod g+s /var/homebridge


Log out of the terminal session and log back in so the permissions take effect

Copy the Homebridge config to the folder made above - cp ~/.homebridge/config.json /var/homebridge/

If you get a permissions error then revisit the above. If it doesn’t work this may effect the homebridge_user as well and it has to be able to write to the /var/homebridge folder

Now you need to setup the config files to run the service on boot. I followed the instructions from here - https://github.com/nfarina/homebridg...a-Raspberry-Pi. Below is what I did.

I copied homebridge and the homebridge.service files to the ~/home/pi/.homebridge with an sftp client. I then moved them to the correct folders. You can download them from here - https://gist.github.com/johannrichar...feb6adb9eb61a/

Now move the files to the correct folders.

sudo mv ~/.homebridge/homebridge /etc/default/homebridge
sudo mv ~/.homebridge/homebridge.service /etc/systemd/system/homebridge.service


sudo nano /etc/systemd/system/homebridge.service

You will need to edit homebridge.service file. Change line 7 from

User=homebridge

To

User=homebridge_user

You can check the file with

cat /etc/systemd/system/homebridge.service

Now we need to make Homebridge run as a service

Before you do that run this command - systemctl status homebridge

This is a not working output

homebridge.service - Node.js HomeKit Server
Loaded: loaded (/etc/systemd/system/homebridge.service; disabled)
Active: inactive (dead)

sudo systemctl daemon-reload
sudo systemctl enable homebridge
sudo systemctl start homebridge



Check the service is running

systemctl status homebridge

This shows it is working output

● homebridge.service - Node.js HomeKit Server
Loaded: loaded (/etc/systemd/system/homebridge.service; enabled)
Active: active (running) since Mon 2016-01-11 06:44:10 UTC; 38s ago
Main PID: 345 (homebridge)
CGroup: /system.slice/homebridge.service
└─345 homebridge

I renamed the user config file in ~/.homebridge so there is no confusion where the config file is running from. It is now in - /var/homebridge/

Now reboot the Raspberry Pi 2 and run - systemctl status homebridge - to check it runs on reboot

My only question now is, can you get the output from Homebridge like you would if you ran it manually. Is there a log you can tail?