Raspberry PI: install Nefit Easy HTTP server

If you want to run commands periodically (say, more than once every few minutes), you should consider running the HTTP server, which opens a connection to the backend at startup and reuses it for all commands sent to it. The HTTP server will (eventually) support all the commands that the CLI tool supports.

This will install the easy-server CLI tool in the /usr/local directory (npm config get prefix will show you where). This library requires Node.js 6.0.0 or later!

sudo npm i nefit-easy-http-server -g
# Install pm2 to control the service
sudo npm install pm2 -g
sudo pm2 startup
touch nefit-easy-http-server.sh
nano nefit-easy-http-server.sh
# Add lines:
#!/bin/bash
/usr/local/bin/easy-server --serial=your-serial --access-key=your-access --password=your-password --host=0.0.0.0 >/dev/null
chmod 755 nefit-easy-http-server.sh
# Start script
pm2 start /home/pi/nefit-easy-http-server.sh
pm2 save