Skip to content

Commit

Permalink
updated to include Google Developer Project Number in DataSourceId
Browse files Browse the repository at this point in the history
  • Loading branch information
bbagnall committed Oct 17, 2018
1 parent 299717d commit ca774d6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ Note :

# Usage
----------------------------
Update the ```config.ini``` with own choices and start the sync using ```python3 app.py```
Get your Google Developer Project Number (a 12 digit number) from a the [Google Developers Console](https://console.developers.google.com/iam-admin/settings)

Update ```project_number``` in ```config.ini``` to be your Google Developer Project Number.

Modify any other variables you'd like in ```config.ini``` with your own choices and start the sync using ```python3 app.py```

Sync examples:
--------------
Expand Down
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def main():

# Init objects
helper = Helper(args.fitbit_creds, args.google_creds)
convertor = Convertor(args.google_creds, None)
convertor = Convertor(args.google_creds, params.get('project_number'), None)
fitbitClient,googleClient = helper.GetFitbitClient(),helper.GetGoogleClient()
remote = Remote(fitbitClient, googleClient, convertor, helper)

Expand Down
5 changes: 5 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# 2. Examples for date values : today, tomorrow, 2 days ago, 2016-08-19
# 3. Beaware of Fitbit rate-limiting when doing full sync for periods longer than 3 weeks.
# 4. body_fat sync has been temporarily. See issue #1.
# 5. project_number comes from https://console.developers.google.com/iam-admin/settings

# Starting date of sync (inclusive)
start_date=2 days ago
Expand All @@ -21,3 +22,7 @@ sync_calories=1
sync_body_fat=1
sync_activities=1
sync_sleep=0


# Google Developer Project Number
project_number=123456789012
7 changes: 6 additions & 1 deletion convertors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ class Convertor:
POUNDS_PER_KILOGRAM = 2.20462
METERS_PER_MILE = 1609.34

def __init__(self, googleCredsFile, tzinfo):
def __init__(self, googleCredsFile, googleDeveloperProjectNumber, tzinfo):
""" Intialize a convertor object.
googleCredsFile -- Google Fits credentials file
tzinfo -- Timezone information of the Fitbit user
"""
self.googleCredsFile = googleCredsFile
self.googleDeveloperProjectNumber = googleDeveloperProjectNumber
self.tzinfo = tzinfo

def UpdateTimezone(self, tzinfo):
Expand Down Expand Up @@ -349,9 +350,13 @@ def GetDataSourceId(self, dataType):
dataType -- type of data. Possible options: steps, weight, heart_rate
"""
dataSource = self.GetDataSource(dataType)
#DataSourceId format
#type:dataType.name:developer-project-number:device.manufacturer:device.model:device.uid:dataStreamName
#reference https://developers.google.com/fit/rest/v1/reference/users/dataSources
return ':'.join((
dataSource['type'],
dataSource['dataType']['name'],
self.googleDeveloperProjectNumber,
dataSource['device']['manufacturer'],
dataSource['device']['model'],
dataSource['device']['uid']))
Expand Down

0 comments on commit ca774d6

Please sign in to comment.