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:
sudo nano /etc/default/homebridgeand paste this gistsudo nano /etc/systemd/system/homebridge.serviceand paste this gist- I had to remove local from:
ExecStart=/usr/local/bin/homebridge $HOMEBRIDGE_OPTSbecause my homebridge installed in /usr/bin/
- I had to remove local from:
- Create a user to run service:
sudo useradd --system homebridge sudo mkdir /var/homebridgesudo 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/homebridgesudo chmod -R 0777 /var/homebridgesudo systemctl daemon-reloadsudo systemctl enable homebridgesudo systemctl start homebridge
Type systemctl status homebridge to check the status of the service.
Type journalctl -f -u homebridge to view the logs
If you are still having issues, try removing the User=homebridge from the homebridge.service file
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.