If you haven't already, install git and node.js on your device.
sudo pip install rrb3
wget https://nodejs.org/dist/v8.9.0/node-v8.9.0-linux-armv6l.tar.gz
tar -xzf node-v8.9.0-linux-armv6l.tar.gz
cd node-v8.9.0-linux-armv6l/
sudo cp -R * /usr/local/
sudo npm install forever -g
sudo npm install axios
(more info https://www.instructables.com/id/Nodejs-App-As-a-RPI-Service-boot-at-Startup/)
Note that this repository should be cloned in /home/pi/tools
, which is hardcoded in the service/googleHome
file.
If you use a different directory, be sure to change that in the googleHome
file.
sudo cp service/googleHome /etc/init.d/
sudo chmod 755 /etc/init.d/googleHome
sudo update-rc.d googleHome defaults
- Fork or clone this repository onto your device.
- In your console, run
npm install
to install the required components. - Run
touch .env
to create your hidden, gitignored environment config file. - In .env, configure your environment as follows:
DEV=
TRUE
if you are on desktop, orFALSE
if you are on your raspberry piPORT=
8000
for development,80
or443
for HTTP or HTTPSPASS=
Whatever you want your password to be
- Run
npm start
to launch the server
When you make a POST request to the server, follow this structure:
http://ipaddresshere/API/switches/sw1?password=yourpasswordhere
You will want to configure the Python files to suit your project's needs.
To add or edit a switch, go into saveState.json. Use the first switch as a guide, and add a new object to the switches array.
You can serve your own frontend out of the public folder, and it will be accessible on the root route if you make a get request to your IP address.