Homekit and Synology Chroot

Well, I can now say I feel as if I have exhausted ALL possibilities and this is not going to work. I even ordered a Wifi dongle for the Synology to see if something had to do with he Synology being on the LAN but not on Wifi. Unfortunately, no luck there. :frowning:

So, looks like there is no way to actually connect to the homebridge running from the Synology and will need to go back to running from a computer on the network. Thanks anyway for trying to get this working.

Now this is VERY interesting… I FINALLY got it to work. HOWEVER, it seems as if with he current set-up you MUST running Terminal on a computer within the network (which completely defeats the purpose of having on the Synology).

Once I opened Terminal on my Mac and SSH into the Synology (not in chroot) I ran the same script you listed to put in the Task Scheduler to start homebridge. It even said that the chroot environment was already started when I ran the script. At that point I was able to connect my iOS Home app to homebridge. The problem is that as soon as you turn off Terminal, homebridge will no longer connect.

Try going in the DSM GUI and opening Chroot GUI and under service tab, add service with /root/.homebridge/run.sh as the launch command, then start it and see if that works.

I just tried to add the service but it does not seem to do anything at all. As soon as I added it the status said “started”. Then when I pushed the “start” button, the status said “stopped”.

Do I need to add anything to the “Status Command” field when building the service?

So, still trying to see if there is a way to auto run on startup as a service directly on the diskstation. I found this link where someone seems to have had the same issue and found a resolution. However, I am not sure how to make that folder they mention:

https://forum.synology.com/enu/viewtopic.php?t=39107

It seems later in the link above some things changed when going to DSM 6, but only related to the high level folder location.

Thanks!

Just as a quick update, I finally came up with a solution…although it was not the most optimal.

What I was able to do is to use an old Windows laptop I had and start the script from there using Putty. I then have the computer set to not turn off, sleep, etc… I also added TeamViewer to the laptop in order to dial-into the laptop just in case it became disconnected.

It is a real shame this can not be run directly (confined) on the Synology but at least this solution will work for now.

Does anyone know if there is a way to edit the config.json file (or maybe something else) in order to change a single switch from an on/off command to open/close?

I find myself always asking Siri to “Open the Garage Door” but she will only turn on/off the garage Door.

The config.json file only connects to the Vera unit. So, I am not sure if there is anything specifically related to the Garage Door (or any other individual device) that can be edited in the config.json file.

Sent from my iPhone using Tapatalk

Hey haven’t been able to troubleshoot this as my phone will not see the server. Probably have to disable/enable iCloud to make it work. Then I might be able to figure out a way to start automatically on Synology. As for the garage door, I do not believe there is a way to configure this specific version of HomeBridge to accept the correct command, but as a workaround, you can create a scene called Open Garage Door to fix it.

Goo days guys!

So… i?ve been trying to set it up on my Synology (DS213) but also got stuck on the npm execution. I also get the error “/root/n/bin/node: 1: /root/n/bin/node: Syntax error: “(” unexpected” when executing the lines.

Any ideas on what is wrong?

Thank you!

That error comes from the fact that the installation routine downloads an Intel package, but your DS213 (as well as mine) runs on ARM. I have tried several other ways, from installing nodejs from source to simply installing nodejs via apt-get as well as trying to install docker - they all fail for various reasons which all boil down to the fact that our DS213 either does not have a 64-bit processor or is no longer supported by current installs. apt-get installs nodejs 0.4.x which works but is less than what is required by homekit.

Bottom line: non-intel Synology machines won’t run homebridge and either need to upgrade to a newer model or use a different computer (like a RPi) for doing (just) the homebridge stuff. Sad but true.

Anyone know if there have been any updates to the Homebridge code in the last month or so? There seem to be additional abilities for HomeKit that have been released and wanted to see if any of these updates will work through a bridge. Thanks!

Sent from my iPhone using Tapatalk

Hey, guys I encounter the same problem. I installed home bridge using the tutorial in the first page on my Sinology DS216j with Terminal. I made the home bridge launch with Terminal and was able to connect to it with my iPhone but I’m not able to make it run automatically with the NAS when I restart it. I got the following error sent to my mail (from the NAS) :

T?che : HomeKitVera start 2
Debian Chroot is already running
Failed to start message bus: The pid file “/var/run/dbus/pid” exists, if the message bus is not running, remove this file
Stopping system message bus: dbus.
Starting system message bus: dbus.
Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon.
/root/.homebridge/run.sh: line 8: homebridge: command not found

Do you thing its possible to launch it, or maybe to creation automated script like when I launching it from Terminal.

Thanks in advance for your help, and sorry for my English :).

Hi,

Som research i’ve done has given that Task scheduler script should look like this:

HOME=/root
source $HOME/.profile
sh /volume1/HomeKitVeraAuto.sh

[quote=“freetz, post:50, topic:194071”]That error comes from the fact that the installation routine downloads an Intel package, but your DS213 (as well as mine) runs on ARM. I have tried several other ways, from installing nodejs from source to simply installing nodejs via apt-get as well as trying to install docker - they all fail for various reasons which all boil down to the fact that our DS213 either does not have a 64-bit processor or is no longer supported by current installs. apt-get installs nodejs 0.4.x which works but is less than what is required by homekit.

Bottom line: non-intel Synology machines won’t run homebridge and either need to upgrade to a newer model or use a different computer (like a RPi) for doing (just) the homebridge stuff. Sad but true.[/quote]

I have Synology DS216j (with CPU MARVELL Armada 385 88F6820) running DSM 6.1-15047 Update 2. I believe this is ARM based as well? Also, I’ve found out that (official) Docker-package is not supported in this model, but is it possible to use the latest Docker package?

Okay, I got this working on my Synology DS216j without Docker and wanted to share instructions for it. Credits to ACN for original post which I revised a bit. Also, here we are installing Veralink by damianxd instead of Hackworth’s version.

  1. Setup a new package source in DSM (see image)

  2. Install the following packages from the SynoCommunity repository:

    Python
    Debian Chroot (see second image)

  3. Run Debian Chroot and wait status: Installed. If it doesn’t happen, reboot your NAS

  4. Open Control Panel Synology and go to Terminal & SNMP. Tick SSH to it.

  5. Open SSH terminal session, login with admin@ and password of your Admin account for Synology

  6. Enter the following commands via SSH session:

    sudo -i
    /var/packages/debian-chroot/scripts/start-stop-status chroot

    • This will open a new root session (exit command takes you back to “base shell”)
      (you’ll see a warning “setlocale: LC_ALL: cannot change locale (en_US.utf8)” which can be ignored for now)

      • Configuring Debian Chroot locales (one-time config):

      apt-get update
      apt-get install aptitude
      aptitude update
      aptitude upgrade
      aptitude install locales
      dpkg-reconfigure locales

      > select there whateverYourLanguageIS.UTF-8 UTF-8 (scroll with the arrow key) and go to OK (Tab key)
      (enter)

      dpkg-reconfigure tzdata
      > Select best option

      • Now installing common packages:

      apt-get install build-essential -y
      apt-get install cmake libboost-dev libboost-thread-dev libboost-system-dev libsqlite3-dev subversion curl libcurl4-openssl-dev libusb-dev zlib1g-dev libudev-dev
      apt-get install git
      apt-get install build-essential libavahi-compat-libdnssd-dev
      apt-get install python

      • In case of conflicts you can use:
        apt-get dist-upgrade
        and/or
        aptitude full-upgrade

      • Install nodejs:
        [i]curl -sL https://deb.nodesource.com/setup_8.x | bash -
        apt-get install -y nodejs

        node -v
        npm -v[/i]

      • mdns install and a bit of editing to resolve some errors:

             [i]npm install mdns[/i]
        
        • edit the following line in ‘/etc/avahi/avahi-daemon.conf’
          rlimit-nproc = 3
          to
          #rlimit-nproc = 3
      • edit /etc/default/avahi-daemon’ and change the line:
        AVAHI_DAEMON_DETECT_LOCAL=1
        to
        AVAHI_DAEMON_DETECT_LOCAL=0

      • try this:
        /etc/init.d/dbus restart

      • if it fails (“can’t start system message bus - /proc is not mounted”), add a following line to /etc/fstab:
        proc /proc proc defaults 0 0

      • start chroot (e.g. from DSM GUI - package center)

      • not sure anymore if the following is needed:
        apt-get install --reinstall avahi-daemon
        /etc/init.d/avahi-daemon restart

      • install pm2 (for running homebridge in the background):

        npm install pm2 -g

      • more packages, including homebridge and the Vera-plugin:

          [i]apt-get install git-core
          npm config set registry http://registry.npmjs.org/
          npm install -g node-gyp  
          npm install -g homebridge
          npm install -g homebridge-vera
        
          mkdir /root/.homebridge/[/i]
        
      • Create your homebridge config.json file

         [i]vi ~/.homebridge/config.json[/i]
        
{
    "bridge": {
        "name": "Homebridge",
        "pin": "121-65-454",
        "username": "CC:22:3D:E3:CE:30"
    },
    "platforms": [
        {
            "platform": "Vera",
            "name": "Vera",
            "veraIP": "<your Vera IP>",
            "includesensor": true,
            "ignorerooms": [],
            "securitypoll": 2000,
            "includethermostat": false,
            "includeRGB": false,          
            "garageLocks": [],
            "Ignoredevices": [],
            "Ignorescenes": [],
            "houseModes": false
        }
    ]
}
  1. To run homebridge in the background and after every reboot, do the following on the Syno shell (not chroot):

    • edit /var/packages/debian-chroot/scripts/start-stop-status:
# Start all services -section:
chroot ${CHROOTTARGET} su - root -c "/etc/init.d/dbus start"
chroot ${CHROOTTARGET} su - root -c "/etc/init.d/avahi-daemon start"
chroot ${CHROOTTARGET} su - root -c "pm2 start homebridge"

# Stop running services -section:
chroot ${CHROOTTARGET} su - root -c "pm2 stop homebridge"
chroot ${CHROOTTARGET} su - root -c "/etc/init.d/avahi-daemon stop"
chroot ${CHROOTTARGET} su - root -c "/etc/init.d/dbus stop"
  1. Final test

    • run the following commands:

      /var/packages/debian-chroot/scripts/start-stop-status stop
      /var/packages/debian-chroot/scripts/start-stop-status start

  2. Now you should be ready to start the Home app on iOS (tested with 10.3.1) and should be able to add this newly made homebridge (using the same pin as in config.json file)

Just wondering if SOMEONE can help with he previous post. My Homebridge was working perfectly until a few days ago. So, I saw this post and tried to rebuild using Chroot since my Synology is one of the one’s without Docker. Everything seems to work fine until I get to the following section:

  • Install nodejs:
    git clone GitHub - nodejs/node: Node.js JavaScript runtime
    cd node
    git checkout v6.10.2 (or the version you want to build)

                ./configure --openssl-libpath=/usr/lib/ssl
      make  (this will take a while...)
      make install
    
      node -v
      npm -v
    

Once I get here, I can get to the line “git checkout v6.10.2” and that works.
I then try to type “./configure --openssl-libpath=/usr/lib/ssl” and get an error that it does not work.
So, I then just type “./configure” which seems to work.
I then type “make” which runs for HOURS (tried this twice and each time takes over 6 hours) only to end with

se/obj.target/v8_snapshot/geni/snapshot.cc" “”
Illegal instruction
deps/v8/tools/gyp/v8_snapshot.target.mk:13: recipe for target ‘/node/out/Release/obj.target/v8_snapshot/geni/snapshot.cc’ failed
make[1]: *** [/node/out/Release/obj.target/v8_snapshot/geni/snapshot.cc] Error 132
make[1]: Leaving directory ‘/node/out’
Makefile:73: recipe for target ‘node’ failed
make: *** [node] Error 2

I then type “make install” and that ends with the same error
Just to check if anything works, I type “node -v” and that says, “bash: node: command not found”

Any ideas on how to help?
I am sure it is just something I am typing wrong following the directions literally but can’t seem to figure this out.

Thanks,!

Same problem

I’m using git checkout v8.5.0 and that works.
“./configure --openssl-libpath=/usr/lib/ssl” does not work.
“./configure” is ok

make[1]: *** [/node/out/Release/obj.target/v8_snapshot/geni/snapshot.cc] Error 132
make[1]: Leaving directory ‘/node/out’
Makefile:73: recipe for target ‘node’ failed
make: *** [node] Error 2

I think problem in this line"./configure –openssl-libpath=/usr/lib/ssl"
but dont understand what to do.
Maybe we need to install more packages ?

Just started experimenting with Homekit om my synology. I have a synology DS214play.
The last tutorial from tunnus did not work for me as well.
I used the instruction from FastFreddi (first post on first page). Big thanks for the tutorial.
Only thing that did not work was the autostartup at boot. I changed the envirement settings in the run.sh file to make it work.

Hi everyone

I followed FastFreddi’s guide and I get Homebridge to run on my Synology DS414 thru SSH (Putty). Thank you!
However I can’t get it to run as a script thru Synology Task Manager…

In my Task manager I have a task executing:

/volume1/NAS/Homekit.sh >>/volume1/NAS/Homekit/tmp/task_debug.out 2>&1

In the Homekit.sh it says

/var/packages/debian-chroot/scripts/start-stop-status start /var/packages/debian-chroot/scripts/start-stop-status chroot /root/.homebridge/run.sh

My task_debug.out gives the error "Debian Chroot is already running /volume1/NAS/Homekit.sh: line 3: /root/.homebridge/run.sh: No such file or directory"
So the forst two commands seem to run, but I can’t get Homebridge to start thru taskmanager.

Any idea please?

Never mind, I got it running with some edits.
I followed FastFreddi’s guide, but you need to enter this in your Synology Task Manager (GUI):

HOME=/root source $HOME/.profile sh /volume1/HomeKitVeraAuto.sh

As stated by alafel (tnx man!).
Now my Homebridge is running fine on my DS414, tnx everyone!

FYI, you can turn on logs for your Synology Task Manager (GUI), this log can tell you wether Homebridge is runing or not!