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.

  1. Add SynoCommunity as Package Center source by following https://synocommunity.com/
  2. Install Debian Chroot from Package Center
  3. SSH to your NAS
  4. sudo -i
  5. /var/packages/debian-chroot/scripts/start-stop-status chroot
  6. apt-get upgrade
  7. apt-get update

Now you are ready to roll.

Build node

The distributed node wasn’t working for me, so I built my own. If apt-get install node can gets you a working version of node, then you can skip this part.

  1. Find a working dir. cd ~ will work fine.
  2. apt-get install build-essential
  3. wget a node tarball from https://nodejs.org/dist/. Recommend 8.1.x.
  4. tar -zxvf <node-tar-filename>
  5. Enter the unpacked node dir.
  6. ./configure
  7. make You can add -j2 to the command if you have dual cores. Even -j4 if you have four cores.
  8. It will take a while to complete.

Install and start dependencies

  1. apt-get install libavahi-compat-libdnssd-dev git
  2. /etc/init.d/dbus start
  3. /etc/init.d/avahi-daemon start

If the last two command failed, try mount -t proc proc proc/ first.

Setup Homebridge

  1. npm install -g --unsafe-perm homebridge
  2. Then install an plugins you need npm install -g --unsafe-perm homebridge-<plugin_name>
  3. 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.

  1. Add a user for the service useradd -s /bin/false -b /var/run homebridge
  2. Copy your .homebridge dir to the new home cp -R ~/.homebridge /var/run/homebridge
  3. Download the content of https://gist.github.com/gregwym/d7b31606758acfb61896f588d13c3dda into /etc/init.d/homebridge
  4. chmod a+x /etc/init.d/homebridge
  5. 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.

Debian Chroot services configuration