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
  3. I had to remove local from: ExecStart=/usr/local/bin/homebridge $HOMEBRIDGE_OPTS because my homebridge installed in /usr/bin/
  4. Create a user to run service: sudo useradd — system homebridge
  5. sudo mkdir /var/homebridge
  6. sudo cp ~/.homebridge/config.json /var/homebridge/
  7. This copies your current user’s config. This assumes you have already added accessories etc.
  8. sudo cp -r ~/.homebridge/persist /var/homebridge
  9. sudo chmod -R 0777 /var/homebridge
  10. sudo systemctl daemon-reload
  11. sudo systemctl enable homebridge
  12. 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.

Originally published at Tim Leland.

Show your support

Clapping shows how much you appreciated Tim’s story.