I’ve been a semi-regular runner since about 2014, when I was briefly inspired to join the navy, so needed to be able to run. Since then, I’ve gone through a series of peaks and troughs in commitment, in a 6 month cycle that has me highly motivated, building up to running a few 5-10k events, then overtraining, getting injured, and stopping for a while. I thought for 2018 I’d aim for a consistent year, and try to avoid too many overtraining injuries, by setting myself of an average of 1 mile a day measured on a 7 day rolling period. This averages out as running 10k a week, (or 5k twice) plus another short recovery run. To track this I decided to create a Strava dashboard using a 7inch touchscreen and my Raspberry Pi 0, which so far has had little use. I planned to have it show a series of graphs & charts showing metrics, and then mount it on the wall to keep me motivated. Simples.
Essentially, all my node-RED instance does is make 3 HTTP requests to the APIs, then manipulate the response into a series of formatted numbers/graph objects, which are then sent to the front-end and displayed. This entire app logic can be seen in the flows below -
I tried to use the built in nodes as much as possible (JSON, change, switch, inject, etc) and avoid function nodes as much as possible. I did have to use a few function nodes to calculate my course records, and generate a rolling average mileage, although I suspect with the fairly new addition of JSONata expressions in certain nodes, I could’ve avoided using these at all. Creating the dashboard was as simple as dragging and dropping the components I wanted, selecting colours, then arranging using the provided grid. Once this was completed, I set my Pi to boot up into kiosk mode, added node-RED to the systemctl processes so it would start on boot, then used inject nodes triggering on a semi-regular basis to set the whole thing off. Then I plugged it all in, mounted on the wall, and I was done!