Setup Homebridge to Start on Bootup

I’ve recently been playing with Homebridge on my Raspberry Pi. I’ve setup my Harmony Hub and my wireless power outlets to be controlled by Siri on my iPhone. Overall it has been pretty simple to setup but I did run into an issue trying to get Homebridge to start on bootup. Homebridge suggest 3 different methods

I decided to use systemd to start Homebridge on bootup. I prefered this method because it will restart if an error occurs. I followed the gist setup step by step but ran into some problems.

My main issues were:

  • The location of my homebridge binary. Step 2
  • Permissions were not correct and the service failed to load. Step 7
  • I needed the persist folder in /var/homebridge directory. Step 6

Here are the steps that worked for me:

  1. sudo nano /etc/default/homebridge and paste this gist
  2. sudo nano /etc/systemd/system/homebridge.service and paste this gist
    1. I had to remove local from:  ExecStart=/usr/local/bin/homebridge $HOMEBRIDGE_OPTS  because my homebridge installed in /usr/bin/
  3. Create a user to run service: useradd –system homebridge
  4. sudo mkdir /var/homebridge
  5. sudo cp ~/.homebridge/config.json /var/homebridge/
    1. This copies your current user’s config. This assumes you have already added accessories etc.
  6. sudo cp -r ~/.homebridge/persist /var/homebridge
  7. sudo chmod -R 0777 /var/homebridge
  8. sudo systemctl daemon-reload
  9. sudo systemctl enable homebridge
  10. sudo systemctl start homebridge

Type systemctl status homebridge to check the status of the service.

Hopefully this helps anyone who is having trouble with Homebridge starting on boot on a Raspberry Pi. Please comment below if you have any questions.

15 thoughts on “Setup Homebridge to Start on Bootup

  1. These instructions were great. However, still no go.

    Firstly, you included ‘sudo’ up to step 8. Then stopped. This correct? Because I get a failure when I don’t include it.

    Now, when I do include it, I get this: ● homebridge.service – Node.js HomeKit Server
    Loaded: loaded (/etc/systemd/system/homebridge.service; enabled)
    Active: activating (auto-restart) (Result: exit-code) since Sat 2016-10-15 00:27:51 UTC; 5s ago
    Process: 3793 ExecStart=/usr/local/bin/homebridge $HOMEBRIDGE_OPTS (code=exited, status=203/EXEC)
    Main PID: 3793 (code=exited, status=203/EXEC)

    Oct 15 00:27:51 raspberrypi systemd[1]: Unit homebridge.service entered fail….
    Hint: Some lines were ellipsized, use -l to show in full.
    [email protected]:~ $
    This error is annoying me. I am pretty new to this, and have followed the steps here and on the other page where you linked from. No luck. Any ideas?

    1. Update: I realised the Exec Start included local, but mine doesn’t. Removed. New Error:
      ● homebridge.service – Node.js HomeKit Server
      Loaded: loaded (/etc/systemd/system/homebridge.service; enabled)
      Active: activating (auto-restart) (Result: exit-code) since Sat 2016-10-15 00:48:22 UTC; 5s ago
      Process: 4409 ExecStart=/usr/bin/homebridge $HOMEBRIDGE_OPTS (code=exited, status=1/FAILURE)
      Main PID: 4409 (code=exited, status=1/FAILURE)

  2. Really appreciate the time you’ve spent with these instructions… worked a charm for me…now have lifx bulbs and nest running thru homekit on a pi3 and I’ve learnt far more than I was expecting! Many thanks

Leave a Reply

Your email address will not be published. Required fields are marked *