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