Setup Homebridge on Synology NAS without Docker
Last weekend I got the IKEA TRÅDFRI kit for my new lamps. It worked OK initially but the app could not connect to gateway after done setup. Since Homekit has always being on my TODO list and controlling lights thru app isn’t quite convenient anyway, I figure it is time to give Homebridge a try.
There are couple docker images. If you have a powerful NAS (prob x86), then Docker is definitely the way to go. But if your are like me, whose NAS doesn’t support Docker and don’t want to setup another 24/7 Raspberry Pi, here is how to setup one without Docker.
Setup Debian Chroot
Why? The native DSM environment doesn’t have required dependency and services. They are not available thru Package Center nor OPKG (aka Entware-ng). With Debian Chroot, you get full apt-get
experience.
- Add SynoCommunity as Package Center source by following https://synocommunity.com/
- Install Debian Chroot from Package Center
- SSH to your NAS
sudo -i
/var/packages/debian-chroot/scripts/start-stop-status chroot
apt-get upgrade
apt-get update
Now you are ready to roll.
Install node
Thru apt-get
curl -sL https://deb.nodesource.com/setup_10.x | build -
apt-get install -y nodejs
This should install node v10.x.
(Alternative) Build yourself
If apt-get install -y nodejs
can gets you a working version of node, then you can skip this part.
- Find a working dir.
cd ~
will work fine. apt-get install build-essential
wget
a node tarball from https://nodejs.org/dist/. Recommend10.x
.tar -zxvf <node-tar-filename>
- Enter the unpacked node dir.
./configure
make
You can add-j2
to the command if you have dual cores. Even-j4
if you have four cores.- It will take a while to complete.
Install and start dependencies
apt-get install libavahi-compat-libdnssd-dev git
/etc/init.d/dbus start
/etc/init.d/avahi-daemon start
If the last two command failed, try mount -t proc proc proc/
first.
Setup Homebridge
npm install -g --unsafe-perm homebridge
- Then install an plugins you need
npm install -g --unsafe-perm homebridge-<plugin_name>
homebridge
it should starts now!
You can follow the instruction in https://github.com/nfarina/homebridge#installation to finish your setup.
Now you can simply run homebridge
in a screen
session to keep it running in the back.
Setup Homebridge as service
Or you can setup it as a service that can auto start after reboots.
- Add a user for the service
useradd -s /bin/false -b /var/run homebridge
- Copy your
.homebridge
dir to the new homecp -R ~/.homebridge /var/run/homebridge
- Download the content of https://gist.github.com/gregwym/d7b31606758acfb61896f588d13c3dda into
/etc/init.d/homebridge
chmod a+x /etc/init.d/homebridge
service homebridge start
Done!
Finally, you can set it to start automatically after reboot in the Debian Chroot DSM UI. On DSM 6, you may need to fix it first by following https://github.com/SynoCommunity/spksrc/issues/1910#issuecomment-253990371.
Add services into Debian Chroot UI as the screenshot bellow, then your homebridge should be all automated now. Cheers.