Google Apps Script for Withings
- Make new Google Spreadsheet.
- Open script editor: Tools->Script editor.
- Add library:
1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF
(OAuth2). - Make new script files, and copy all gs files in this repository.
- Add properties:
- Add following properties (Manage script properties manually):
CLIENT_ID
: CLIENT_ID of API.CLIENT_SECRET
: CLIENT_SECRET of API.EMAIL
: Optional. If not set, use the email address of script owner to notify errors.
- CLIENT_ID and CLIENT_SECRET can be found as following:
- Make sure you have a Withings account.
- Register as Withings API partner here.
- callback function should be like:
https://script.google.com/macros/d/<SCRIPT_ID>/usercallback
SCRIPT_ID
is found in the menu of Apps Script: File -> Project properties -> Script Id
- callback function should be like:
- Get client id and client (consumer) secret.
- Add following properties (Manage script properties manually):
Edit params.gs if you want to change the parameters.
Open Measure.gs
and run function body
.
Open Sleep.gs
and run function sleepSummary
.
It is good to schedule the job to retrieve messages every day.
- Go
Trigger
(Clock icon) in the Apps Script project. Add Trigger
- Choose which function to run:
body
- Which runs at deployment:
Head
- Select event source:
Time-driven
- Select type of time based trigger:
Day timer
- Select time of day:
0 am to 1 am
- Choose which function to run:
This trigger fill body data between 0 am to 1 am every day.
Set a trigger for sleepSummary
as well.