/MMM-withings

A Magic Mirror module for displaying health information from Withings Health API

Primary LanguageJavaScriptMIT LicenseMIT

Module: MMM-withings

The MMM-withings module is an extension for MagicMirror. It provides a way to display data from the Withings Health API in HTML5 plots using Chart.js

screenshot

Setting Up API Key and User Account

The following steps are necessary to use this module:

  1. Have a withings account:
  2. Navigate to here to create an application (can be a fake application)
    1. Application Name: Can be anything
    2. Description: Can be anything
    3. Contact Email: Your Email
    4. Callback URL: Your HTTPS website/callback URL or https://example.com
    5. Application Website: Your Website or https://example.com
    6. Company: Your company or whatever you want
    7. Logo: An image file that meets requirements. 'logo.jpg' In this repo works.
  3. Populate config.js with the clientId, consumerSecret, and redirectUri (the Callback URL):
{
    module: "MMM-withings",
    config: {
        clientId: 'deadbeefdeadbeef',
        clientSecret: 'deadbeefdeadbeef',
        redirectUri: 'https://example.com',
    }
},
  1. Once you have a client ID and consumer secret created, create and navigate to the following website
https://account.health.nokia.com/oauth2_user/authorize2?response_type=code&redirect_uri=https://example.com&scope=user.info,user.metrics,user.activity&state=1&client_id=<your_client_id>
  1. Login with your account credentials
  2. Allow this app
  3. You will be redirected to an example.com url with a code in the url E.g.
https://example.com/?state=1&code=deadbeefcafebabe12345789
  1. Copy the value for code into tokens.json in the following format
{
    "code":"deadbeefcafebabe12345789"
}
  1. Start Magic Mirror within 30 seconds. On first run, an access/refresh token will be generated. If access code is unable to be generated, an attempt will be made in 30 seconds. Simply repeat steps 4-8, and an access token should be able to be generated.

Using the module

To use this module, add it to the modules array in the config/config.js file:

modules: [
    {
        module: "MMM-withings",
        position: "bottom_bar",	// This can be any of the regions.
        config: {
            // See 'Configuration options' for more information.
            units: 'imperial',
            measurements: ['weight', 'fatRatio']
        }
    }
]

Configuration options

The following properties can be configured:

Option Description
units Units to display

Default value: config.units
userName Name of user

Default value: MagicMirror
clientId Client Id from step 3

Default value: ``
clientSecret Consumer Secret from step 3

Default value: ``
redirectUri Callback URL from step 3

Default value: ``
initialLoadDelay Delay for first check

Default value: 0
updateInterval Update interval in milliseconds

Default value: 5 Minutes
daysOfHistory Days of data history to fetch

Default value: 14
measurements Array of measurements to check
Possible values: weight, height, fatFreeMass, fatRatio, fatMassWeight, diastolicBloodPressure, systolicBloodPressure, heartPulse, temperature, sp02, bodyTemperature, skinTemperature, muscleMass, hydration, boneMass, pulseWaveVelocity
Example: ['weight', 'fatRatio']
Default value: ['weight']