Skip to content

Instantly share code, notes, and snippets.

@AJ-Acevedo
Last active January 10, 2022 03:48
Show Gist options
  • Save AJ-Acevedo/47d5eaf669f40811f66aaf25bf1ad57e to your computer and use it in GitHub Desktop.
Save AJ-Acevedo/47d5eaf669f40811f66aaf25bf1ad57e to your computer and use it in GitHub Desktop.
Peloton Power Zone Calculator
#!/usr/bin/env bash
# AJAlabs.com
#
# Peloton Power Zone Calculator
# v0.3
#
# LICENSE: MIT LICENSE (https://opensource.org/licenses/MIT)
set -e
# Colors
txt_red="\033[31m" # Red
txt_green="\033[32m" # Green
txt_yellow="\033[33m" # Yellow
txt_blue="\033[36m" # Blue
txt_reset="\033[0m" # Reset the prompt back to the default color
# Let's get started
clear
echo -e "$txt_blue""Peloton FTP Power Zones Calculator\n""$txt_reset"
echo -e "$txt_blue""This script will calculate your Peloton FTP Power Zones based on your 20 minute average output.\nPlease see the following link for more information.\nhttps://blog.onepeloton.com/power-zone-rides-everything-need-know ""$txt_reset"
echo -e "$txt_green""\nType your 20 minute average output, then press [ENTER]:""$txt_reset"
read averageOutput
# While $averageOutput is blank or not a valid integer, loop user input prompt.
until [ $averageOutput -eq $averageOutput 2> /dev/null ] && [ $averageOutput != '' 2> /dev/null ]; do
echo -e "$txt_red""\nPlease enter your 20 minute average output using only numbers, then press the enter/return key:""$txt_reset"
read averageOutput
done
# Determine FTP which is 95% of the 20 minute average output
ftp=$((($averageOutput*95)/100))
# Determine Zone 1 (55% of FTP)
zoneOne=$((($ftp*55)/100))
# Determine Zone 2 (56-75% of FTP)
zoneTwoStart=$((($ftp*56)/100))
zoneTwoEnd=$((($ftp*75)/100))
# Determine Zone 3 (76-90% of FTP)
zoneThreeStart=$((($ftp*76)/100))
zoneThreeEnd=$((($ftp*90)/100))
# Determine Zone 4 (91-105% of FTP)
zoneFourStart=$((($ftp*91)/100))
zoneFourEnd=$((($ftp*105)/100))
# Determine Zone 5 (106-120% of FTP)
zoneFiveStart=$((($ftp*106)/100))
zoneFiveEnd=$((($ftp*120)/100))
# Determine Zone 6 (121-150% of FTP)
zoneSixStart=$((($ftp*121)/100))
zoneSixEnd=$((($ftp*150)/100))
# Determine Zone 7 (151% of FTP)
zoneSeven=$((($ftp*151)/100))
# Output the Power Zones
echo -e "\n$txt_blue""FTP: $ftp""$txt_reset"
echo -e "$txt_blue""Zone 1: < $zoneOne""$txt_reset"
echo -e "$txt_blue""Zone 2: $zoneTwoStart to $zoneTwoEnd""$txt_reset"
echo -e "$txt_blue""Zone 3: $zoneThreeStart to $zoneThreeEnd""$txt_reset"
echo -e "$txt_blue""Zone 4: $zoneFourStart to $zoneFourEnd""$txt_reset"
echo -e "$txt_blue""Zone 5: $zoneFiveStart to $zoneFiveEnd""$txt_reset"
echo -e "$txt_blue""Zone 6: $zoneSixStart to $zoneSixEnd""$txt_reset"
echo -e "$txt_blue""Zone 7: > $zoneSeven""$txt_reset\n"
@ctmay4
Copy link

ctmay4 commented Jan 1, 2018

Looks like there is a bug in your calculation. The zones are supposed to be calculated based on the FTP (according the the PDF on the blog post), not the average output. You calculate FTP but then do not use it in the zone calculations.

Here is a corrected script. Thanks for putting it together!

#!/usr/bin/env bash

# AJAlabs.com
#
# Peloton Power Zone Calculator
# v0.1
#

# Colors
txt_red="\033[31m"    # Red
txt_green="\033[32m"  # Green
txt_yellow="\033[33m" # Yellow
txt_blue="\033[36m"   # Blue
txt_reset="\033[0m"   # Reset the prompt back to the default color

# Let's get started
clear
echo -e "$txt_blue""Peloton FTP Power Zones Calculator\n""$txt_reset"
echo -e "$txt_blue""This script will calculate your Peloton FTP Power Zones based on your 20 minute average output.\nPlease see the following link for more information.\nhttps://blog.onepeloton.com/power-zone-rides-everything-need-know ""$txt_reset"

echo -e "$txt_green""\nType your 20 minute average output, then press [ENTER]:""$txt_reset"
read averageOutput

#TODO: While $averageOutput is blank or not a valid integer, loop user input prompt.

# FTP is 95% of the 20 minute average output
ftp=$((($averageOutput*95)/100))

# Determine Zone 1 (55% of FTP)
zoneOne=$((($ftp*55)/100))

# Determine Zone 2 (56-75% of FTP)
zoneTwoStart=$((($ftp*56)/100))
zoneTwoEnd=$((($ftp*75)/100))

# Determine Zone 3 (76-90% of FTP)
zoneThreeStart=$((($ftp*76)/100))
zoneThreeEnd=$((($ftp*90)/100))

# Determine Zone 4 (91-105% of FTP)
zoneFourStart=$((($ftp*91)/100))
zoneFourEnd=$((($ftp*105)/100))

# Determine Zone 5 (106-120% of FTP)
zoneFiveStart=$((($ftp*106)/100))
zoneFiveEnd=$((($ftp*120)/100))

# Determine Zone 6 (121-150% of FTP)
zoneSixStart=$((($ftp*121)/100))
zoneSixEnd=$((($ftp*150)/100))

# Determine Zone 7 (151% of FTP)
zoneSeven=$((($ftp*151)/100))

echo -e "\n$txt_blue""Your FTP is: $ftp""$txt_reset"
echo -e "$txt_blue""Zone 1: < $zoneOne""$txt_reset"
echo -e "$txt_blue""Zone 2: $zoneTwoStart to $zoneTwoEnd""$txt_reset"
echo -e "$txt_blue""Zone 3: $zoneThreeStart to $zoneThreeEnd""$txt_reset"
echo -e "$txt_blue""Zone 4: $zoneFourStart to $zoneFourEnd""$txt_reset"
echo -e "$txt_blue""Zone 5: $zoneFiveStart to $zoneFiveEnd""$txt_reset"
echo -e "$txt_blue""Zone 6: $zoneSixStart to $zoneSixEnd""$txt_reset"
echo -e "$txt_blue""Zone 7: > $zoneSeven""$txt_reset\n"

@AJ-Acevedo
Copy link
Author

AJ-Acevedo commented Jan 1, 2018

@ctmay4 Thanks for refactoring and fixing the bug. Looks great! I updated the script to v0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment