-
Notifications
You must be signed in to change notification settings - Fork 40
(RPi) Start HAP on Reboot
This page has instructions on how to start HAP-NodeJS during boot, on your Raspberry Pi!
Ensure you have setup the 'Wait for Boot' process. If you haven't, follow the steps in this link here.
###Also, ensure your HAP-NodeJS directory is /home/pi/HAP-NodeJS. If you used my video to install, you should be fine.
The first command you want to run is: cd ~
This command returns you to your home directory.
The second command you want to run is: sudo npm install forever -g
This command starts the forever installation process. This can take 5-10 minutes. If it takes longer, reboot your Raspberry Pi
The next command you want to run is: sudo nano /start
This command opens nano and allows you to edit the start script. Add the following lines:
sudo forever stopall
cd /home/pi/HAP-NodeJS
sudo forever start BridgedCore.js
Change BridgedCore.js to Core.js if you are using Core.js.
If you are ONLY using CameraCore.js, change BridgedCore.js to CameraCore.js.
Add this additional line at the end if you are using CameraCore.js alongside Core/BridgedCore.js:
sudo forever start CameraCore.js
Once you are done, save the file and exit nano.
The next command you want to run is: sudo chmod +x /start
This command sets the start script to an executable script
The next command you want to run is: sudo nano /etc/rc.local
This command opens nano and allows you to edit the rc.local file
Now, you want to add code before the "exit 0" line. Add this line before "exit 0":
sudo sh /start
This tells the Raspberry Pi to start HAP-NodeJS at startup
Save and exit the rc.local file once you are done. Then, reboot your Pi and HAP-NodeJS should automatically start!
Learn more about forever here.