MMM Strava Save

A MagicMirror Module for your Strava data.

Project README

MagicMirror Module: MMM-Strava

A MagicMirror Module for displaying your Strava data.

Platform License Test Status Code Climate Known Vulnerabilities

Example

Table mode screenshot Chart mode screenshot

The module displays activity information in one of two modes

  • table mode, which displays a table showing the number of activities, the total distance and (for recent period only) the number of achievements.
  • chart mode, which displays the total distance, moving time and elevation gain alongside a chart showing the total distance grouped by
    • day (for recent period),
    • month (for ytd period),
    • year (for all period).

In addition you can configure the following options

  • Which activities (and the order activities) should be displayed.
  • Which stats should be displayed.
    • The number of activities (count).
    • The total distance (distance).
    • The total elevation gain (elevation).
    • The total moving time for the period. (moving_time).
    • The total elapsed time for the period. (elapsed_time).
    • The total number of achievements (achievements) - in table mode, only available for recent period).
  • Which period to display stats for your activities:
    • "recent" - last 4 weeks in table mode or current week in chart mode.
    • "ytd" - current year to date.
    • "all" - all time.
  • Which chartType should be used in chart mode:
    • "bar" - a simple bar chart.
    • "radial" - a radial histogram Beta.
  • The firstYear to group activities by in chart mode when the period is "all".
  • Whether the module should auto_rotate through the different periods, and the updateInterval between rotations. (only applicable in table mode).
  • The units (miles/feet or kilometres/metres) used to display the total distance and elevation gain statistics.
  • The locale used for determining the date (day or month) labels in chart mode and number format in both modes.
  • The number of decimal digits displayed for the total distance and elevation gain statistics.

Installation

  1. Stop your MagicMirror and clone the repository into the modules folder

    cd ~/MagicMirror/modules
    git clone https://github.com/ianperrin/MMM-Strava.git
    cd ~/MagicMirror/modules/MMM-Strava
    npm install --production
    
  2. Create a Strava API Application and note the client_id and client_secret

    • Browse to your My API Application page and log in to Strava if prompted.
    • Make sure the callback domain matches the IP address (or URL) used to access the MagicMirror.
    • Make a note of the client_id and client_secret
  3. Add the module to the config file (~/MagicMirror/config/config.js) for your mirror.

    modules: [
      {
        module: "MMM-Strava",
        position: "top_right",
        config: {
          client_id: "your_strava_client_id",
          client_secret: "your_strava_api_client_secret"
        }
      }
    ];
    

    The full list of config options can be found in the configuration options table.

  4. Restart the MagicMirror

    pm2 restart mm
    
  5. Authenticate the module to allow access to the Strava API.

    • Browse to the Strava authentication page: http://localhost:8080/MMM-Strava/auth/ - the exact URL may vary depending on your configuration.
    • Select the module you wish to authenticate (e.g. module_4_MMM-Strava) and click/tap Authorise -The number of the modules will vary depending on your configuration.
    • On the Strava Authorisation page, select the level of access you wish to give to the Magic Mirror, and click/tap Authorize - the module requires at least View data about your public profile and View data about your activities but it's up to you whether you want to allow access to private activities.
    • Once the successful authorisation message appears, restart your Magic Mirror.

Updating the module

To update the module to the latest version,

  1. Pull the changes from this repository into the MMM-Strava folder:

    cd ~/MagicMirror/modules/MMM-Strava
    git pull
    npm install --production
    
  2. Update your config file to remove the strava_id and access_token options and add the new client_id and client_secret options - See steps 2 and 4 in the installation notes.

Please Note Following the changes to Strava’s authentication model, the client_id and client_secret must be included in the config in place of the deprecated strava_id and access_token options.

If you haven't changed the module, this should work without any problems. If you have a problem, you can reset the module using git reset --hard, after which git pull should be possible. You may wish to use git status to see any changes before doing so.

Configuration options

The following properties can be added to the configuration:

Option Default Description Possible Values
client_id Required - The Client ID for your Strava API Application, obtained from your My API Application page.
client_secret Required - The Client Secret for your Strava API Application, obtained from your My API Application page.
mode table Optional - Determines which mode should be used to display activity information. "table", "chart"
chartType Beta bar Optional - Determines the type of chert which should be displayed in chart. "bar", "radial"
activities ["ride", "run", "swim"] Optional - Determines which activities to display and in which order they are displayed. Note: - The activities can be listed in any order, and only one is required. However, they must be entered as an array of strings i.e. comma separated values within square brackets. In table mode: "ride", "run", "swim"
In chart mode: "alpineski", "backcountryski", "canoeing", "crossfit", "ebikeride", "elliptical", "golf", "handcycle", "hike", "iceskate", "inlineskate", "kayaking", "kitesurf", "nordicski", "ride", "rockclimbing", "rollerski", "rowing", "run", "sail", "skateboard", "snowboard", "snowshoe", "soccer", "stairstepper", "standuppaddling", "surfing", "swim", "velomobile", "virtualride", "virtualrun", "walk", "weighttraining", "wheelchair", "windsurf", "workout", "yoga"
period recent Optional - What period should be used to summarise the activities in table and chart mode. recent = last 4 weeks in table mode or current week in chart mode, ytd = year to date, all = all time
stats In table mode: ["count", "distance", "achievements"]
In chart mode: ["distance", "moving_time", "elevation"]
Optional - Determines which statistics to display.
Note: - The stats can be listed in any order, and only one is required. However, they must be entered as an array of strings i.e. comma separated values within square brackets.
"count", "distance", "elevation", "moving_time", "elapsed_time", "achievements"
auto_rotate false Optional - Whether the summary of activities should rotate through the different periods in table mode. true = rotates the summary through the different periods, false = displays the specified period only.
units config.units Optional - What units to use. Specified by config.js config.units = Specified by config.js, metric = Kilometres/Metres, imperial = Miles/Feet
updateInterval 10000 (10 seconds) Optional - How often does the period have to change? (Milliseconds). 1000 - 86400000
reloadInterval 300000 (5 minutes) Optional - How often does the data needs to be reloaded from the API? (Milliseconds). See Strava documentation for API rate limits 7500 - 86400000
animationSpeed 2500 Optional - The speed of the update animation. (Milliseconds) 0 - 5000
locale config.language Optional - The locale to be used for displaying dates - e.g. the days of the week or months or the year in chart mode. If omitted, the config.language will be used. e.g. en, en-gb, fr etc
debug false Optional - Outputs extended logging to the console/log true = enables extended logging, false = disables extended logging
digits 1 Optional - Digits for total distance and elevation gain statistics 0 - ...
firstYear Five years before the current date. Optional - The first year activities should be grouped by in chart mode when the period is "all". 0 - ...
Open Source Agenda is not affiliated with "MMM Strava" Project. README Source: ianperrin/MMM-Strava
Stars
48
Open Issues
16
Last Commit
11 months ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating