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
The module needs access to your Withings data in order to display it. The authorization is restricted to localhost. This feature can be disabled from config.js and an API key can be manually generated and used following these instructions.
- Ensure you have a registered Withings account
- Launch Magic Mirror with withings module included.
- After some time, the default browser will open on the default display linking to withings.com with a prompt to login.
- Log in with Withings account, and authorize Personal Mirror Project
- After page returns with OK, you can close the browser. Data should start loading into the Withings 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']
}
}
]
The following properties can be configured:
Option | Description |
---|---|
units |
Units to display Default value: config.units |
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'] |
userName |
Name of user Default value: MagicMirror |
attemptAuthorization |
Attempt authorization using default app. If false, use these instructions for generating API key Default value: true |
clientId |
Client Id from step 3 Default value: `` |
clientSecret |
Consumer Secret from step 3 Default value: `` |
redirectUri |
Callback URL from step 3 Default value: `` |
- Have a withings account
- Navigate to here to create an application (can be a fake application)
- Application Name: Can be anything
- Description: Can be anything
- Contact Email: Your Email
- Callback URL: Your HTTPS website/callback URL or https://example.com
- Application Website: Your Website or https://example.com
- Company: Your company or whatever you want
- Logo: An image file that meets requirements. 'logo.jpg' In this repo works.
- Populate config.js with the clientId, consumerSecret, and redirectUri (the Callback URL):
{
module: "MMM-withings",
config: {
clientId: 'deadbeefdeadbeef',
clientSecret: 'deadbeefdeadbeef',
redirectUri: 'https://example.com',
}
},
- Once you have a client ID and consumer secret created, create and navigate to the following website
https://account.withings.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>
- Login with your account credentials
- Allow this app
- You will be redirected to an example.com url with a code in the url E.g.
https://example.com/?state=1&code=deadbeefcafebabe12345789
- Copy the value for code into tokens.json in the following format
{
"code":"deadbeefcafebabe12345789"
}
- 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.