Git Product home page Git Product logo

Comments (1)

jikamens avatar jikamens commented on August 17, 2024

This seems to help, kind of, maybe, but I'm not certain:

diff --git a/remote.py b/remote.py
index ad9a639..5bbc739 100644
--- a/remote.py
+++ b/remote.py
@@ -259,6 +259,7 @@ class Remote:
 		# Fitbit activities list endpoint is in beta stage. It may break in the future and not directly supported
 		# by the python client library.
 		dataSourceId = self.convertor.GetDataSourceId('activity')
+		distanceDataSourceId = self.convertor.GetDataSourceId('distance')
 		if not callurl:
 			callurl = '{}/user/-/activities/list.json?afterDate={}&sort=asc&offset=0&limit=20'.format(self.FITBIT_API_URL,start_date)
 		activities_raw = self.ReadFromFitbit(self.fitbitClient.make_request, callurl)
@@ -279,6 +280,17 @@ class Remote:
 				)
 			self.WriteToGoogleFit(dataSourceId, [activity_segment])
 
+			if "distance" in activity:
+				if activity["distanceUnit"] != 'Mile':
+					raise Exception("Don't know how to deal with distance unit {}".format(
+						activity["distanceUnit"]))
+				distance_delta = dict(
+					dataTypeName='com.google.distance.delta',
+					startTimeNanos=activity_segment['startTimeNanos'],
+					endTimeNanos=activity_segment['endTimeNanos'],
+					value=[dict(fpVal=activity['distance'] * self.convertor.METERS_PER_MILE)])
+				self.WriteToGoogleFit(distanceDataSourceId, [distance_delta])
+
 			# Just for user output
 			startTimeMillis.append(google_session['startTimeMillis'])
 			endTimeMillis.append(google_session['endTimeMillis'])

Weirdly, it seems like activities sync'd with this patch show up in the Android Google Fit app but not on fit.google.com.

from fitbit-googlefit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.