Code Monkey home page Code Monkey logo

peloton-to-garmin's People

Contributors

0xhiteshpatel avatar actions-user avatar agent462 avatar anlesk avatar chris-mosley avatar dependabot[bot] avatar dkuwahara avatar douglasawh avatar gavdraper avatar geoffbon avatar gregchung-ibfl avatar jheizer avatar jyc66 avatar kdisimone avatar kocolosk avatar nateeverden avatar philjn avatar philosowaffle avatar ricardoniepel avatar rudiejd avatar ryanmac8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

peloton-to-garmin's Issues

Just ride workouts are not being converted

I only have two Jist Ride workouts in peloton. When I run the script, I'm getting:

2019-12-12 09:50:41,028 - ERROR - peloton-to-garmin: Failed to write TCX file for workout a854899814b14b37bb3d1fd110f4180c - Exception: 'NoneType' object is not subscriptable

To fix that, I've changed the way ride details being pulled out of workout data:
totalTimeSeconds.text = str(workout["ride"]["duration"])
instead of
totalTimeSeconds.text = str(workout["peloton"]["ride"]["duration"])

As well as commenting out the whole logic around parsing instruction name. For some reason, that didn't work:
if workout['ride']['instructor'] is not None:
as workout actually has instructor:
"instructor": { "image_url": "https://s3.amazonaws.com/peloton-ride-images/just-ride.png", "name": "JUST RIDE" },

Garmin Upload Error again

I'm using the latest 1.1.0 and I'm getting an "AssertionError: Failed to authenticate garmin user." error. Anyone else getting this?

Not counting towards badges.

I am not sure this old or new, Since I started using this process after my March Badges were complete. But it appears that the Peloton activity (Walk and Cycling) did not get counted towards my badges for Garmin. Is this normal and is there anything we can do to fix this. I guess I could start the process on my watch and then manually enter the mileage afterward. Just seems redundant.

[Docker] syncHistory.json no way to modify

When running in docker there is currently no way to access/modify the syncHistory.json. Users should have the option to do this so they can manage re-uploading previous workouts.

API Error when downloading workouts

Hey! I'm running the code from the docker image and failing to import any.

For "Just Ride" workouts, using peloton or peloton.ride or other combinations of this in ?joins causing the application to fail.

Here is the console log:

2020-12-10 04:24:26,696 - INFO - peloton-to-garmin: Get latest 1 workouts. 2020-12-10 04:24:26,756 - INFO - peloton-to-garmin: Get workout: 35b4d08262014fe58b77018388f151f7 2020-12-10 04:24:26,793 - ERROR - peloton-to-garmin.Util: handle_error - Url: https://api.pelotoncycle.com/api/workout/35b4d08262014fe58b77018388f151f7?joins=peloton,peloton.ride,peloton.ride.instructor,user 2020-12-10 04:24:26,794 - ERROR - peloton-to-garmin.Util: handle_error - Headers: {'User-Agent': 'python-requests/2.24.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Cookie': '__cfduid=d15f9738116636a24bf3ca2a8190ef2d91607574266; __cfruid=241c31948516ce6bc439a7986a032f156c0ee809-1607574266; peloton_session_id=3e7d0d8db54d4988a690b7037acf4538; peloton_session_id=3e7d0d8db54d4988a690b7037acf4538', 'Content-Length': '2', 'Content-Type': 'application/json'} 2020-12-10 04:24:26,794 - ERROR - peloton-to-garmin.Util: Exception: 400: Request was invalid

I tried to curl https://api.pelotoncycle.com/api/workout/35b4d08262014fe58b77018388f151f7?joins=peloton,peloton.ride,peloton.ride.instructor,user and got as response:
{ "status": 400, "error_code": 2120, "subcode": null, "message": "Bad joins", "details": null }

However, if I remove peloton from the query - it works as expected:
https://api.pelotoncycle.com/api/workout/35b4d08262014fe58b77018388f151f7?joins=ride,ride.instructor,user

{ "created_at": 1607559539, "device_type": "home_bike_v1", "end_time": 1607563742, "fitbit_id": null, "fitness_discipline": "cycling", "has_pedaling_metrics": true, "has_leaderboard_metrics": false, "id": "35b4d08262014fe58b77018388f151f7", "is_total_work_personal_record": false, "metrics_type": "cycling", "name": "Cycling Workout", "peloton_id": null, "platform": "commercial_bike", "start_time": 1607559541, "strava_id": null, "status": "COMPLETE", "timezone": "America/New_York", "title": "70 min 1 sec Just Ride", "total_work": 974721.83, "user_id": "0724e6f65c88492fb963517c4b3fb9e9", "workout_type": "freestyle", "total_video_watch_time_seconds": 0, "total_video_buffering_seconds": 0, "v2_total_video_watch_time_seconds": null, "v2_total_video_buffering_seconds": null, "ride": { "id": "00000000000000000000000000000000", "is_archived": false, "instructor": { "name": "JUST RIDE", "image_url": "https://s3.amazonaws.com/peloton-ride-images/just-ride.png" }, "title": "70 min 1 sec Just Ride", "scheduled_start_time": 1607559539, "duration": 4201 }, "device_type_display_name": "Bike" }

Failed to Parse Distance

Hi there,

Firstly thanks so much for writing this amazing library, super helpful. Not sure if this has or is being addressed. I have set my peloton to record miles (as I saw that's what it needed to be on for this to work) how ever I get this error when running the script.

  • Exception: list index out of range

On V2 branch, workouts with identical names end up over-writing each other and not getting uploaded to Garmin

I tried to sync my entire Peloton history to my Garmin account. Workouts contain a timestamp for length and this mostly makes them unique when they are being written to file. For example:

33_min_26_sec_Just_Ride_with_JUST_RIDE.fit

I noticed that some of my arm workouts on the same workout video are missing. My theory is that because the names are exactly identical, only one got uploaded from the whole set. This is corroborated by the fact that enabling backup only generates a single .fit file for this workout, even though there are several that should have been created:

10_min_Arms_&_Shoulders_Strength_with_Ben_Alldis.fit

I can see that the downloader is pulling multiple workouts, but my guess is the uploader only ends up only getting one due to the naming collision:

2021-05-03 20:30:14.894 -07:00 [INF] Encoded FIT file C:\P2G\working\10_min_Arms_&_Shoulders_Strength_with_Ben_Alldis.fit
2021-05-03 20:30:14.898 -07:00 [INF] Backed up file ./output\fit\10_min_Arms_&_Shoulders_Strength_with_Ben_Alldis.fit
2021-05-03 20:30:14.938 -07:00 [INF] Encoded FIT file C:\P2G\working\10_min_Arms_&_Shoulders_Strength_with_Ben_Alldis.fit
2021-05-03 20:30:14.942 -07:00 [INF] Backed up file ./output\fit\10_min_Arms_&_Shoulders_Strength_with_Ben_Alldis.fit

Proposal would be to add some unique hash or other identifier (date/time) to these to avoid collisions.

Workout not converting

2021-04-18 18:59:04.982 +00:00 [ERR] Uncaught Exception.
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Conversion.FitConverter.GetWorkoutStepsAndLaps(WorkoutSamples workoutSamples, DateTime startTime, Sport sport, SubSport subSport) in /buil$
at Conversion.FitConverter.Convert(Workout workout, WorkoutSamples workoutSamples, WorkoutSummary workoutSummary) in /build/src/Conversion/Fi$
at Conversion.Converter`1.Convert(String format) in /build/src/Conversion/IConverter.cs:line 51
at Conversion.FitConverter.Convert() in /build/src/Conversion/FitConverter.cs:line 27
at PelotonToGarminConsole.Program.RunAsync(Configuration config) in /build/src/PelotonToGarminConsole/Program.cs:line 119
at PelotonToGarminConsole.Program.Main(String[] args) in /build/src/PelotonToGarminConsole/Program.cs:line 84

Waiting for more info on what the workout type was.

Failing to download files due to API error

How many past activities do you want to grab? 3
2020-12-16 15:12:32,916 - INFO - peloton-to-garmin: Get latest 3 workouts.
2020-12-16 15:12:33,281 - INFO - peloton-to-garmin: Get workout: 18753dcc467f4f63b9ff1f2c23d53de4
2020-12-16 15:12:33,603 - ERROR - peloton-to-garmin.Util: handle_error - Url: https://api.pelotoncycle.com/api/workout/18753dcc467f4f63b9ff1f2c23d53de4?joins=peloton,peloton.ride,peloton.ride.instructor,user
2020-12-16 15:12:33,604 - ERROR - peloton-to-garmin.Util: handle_error - Headers: {'User-Agent': 'python-requests/2.24.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'Connection': 'keep-alive', 'Cookie': '__cfduid=d5f0dc5c1068ea762f9828845632af0c71608160349; __cfruid=9604582256407400d87e2b484078292b948a86ef-1608160352; peloton_session_id=1a11afe97dae47d3a86e04249efc46c3; peloton_session_id=1a11afe97dae47d3a86e04249efc46c3', 'Content-Length': '2', 'Content-Type': 'application/json'}

":" in workout title causes file creation failure

When a colon (":") exists in workout title (see "15 min Move for More: Climb Ride") it causes python parser to fail w/o throwing error in terminal. An empty file is created, no extension and filename stops at point of colon.

Example workout: json. Issued is caused in tcx_builder.py at line 205 workout["ride"]["title"]. I worked around by changing title to rating, but not a long-term fix.

On V2 branch, from clean ZIP install, missing an empty syncHistory.json causes an exception

Downloading the distribution ZIP from latest V2 branch, unzipping and configuring using the configuration JSON and then running the console app will crash with a file not found exception when looking for the syncHistory.json file as it does not exist.

To workaround, you must create the DB file by hand and put an empty JSON object into it:

.\output\syncHistory.json

{}

Note that path may need to be adjusted if the configuration file property SyncHistoryDbPath was changed. Once this file exists, the sync runs as expected.

Also note that this only seems to happen on first run. If I delete the syncHistory.json file after a sync is finished, it will re-create the file correctly.

One final detail is that the directory does exist (even though the exception claims it is a directory missing error) -- only the file is missing:

PS C:\P2G> dir output
    Directory: C:\P2G\output

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         5/3/2021   8:22 PM           1520 log20210503.txt

Exception text is below:

System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\P2G\output\syncHistory.json'.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)
   at System.IO.File.InternalReadAllText(String path, Encoding encoding)
   at System.IO.File.ReadAllText(String path)
   at JsonFlatFileDataStore.DataStore.ReadJsonFromFile(String path)
   at JsonFlatFileDataStore.DataStore..ctor(String path, Boolean useLowerCamelCase, String keyProperty, Boolean reloadBeforeGetCollection)
   at Common.Database.DbClient..ctor(Configuration configuration) in /home/runner/work/peloton-to-garmin/peloton-to-garmin/src/Common/Database/DbClient.cs:line 27
   at PelotonToGarminConsole.Program.RunAsync(Configuration config) in /home/runner/work/peloton-to-garmin/peloton-to-garmin/src/PelotonToGarminConsole/Program.cs:line 120
   at PelotonToGarminConsole.Program.Main(String[] args) in /home/runner/work/peloton-to-garmin/peloton-to-garmin/src/PelotonToGarminConsole/Program.cs:line 93
Unhandled exception. System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\P2G\output\syncHistory.json'.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)
   at System.IO.File.InternalReadAllText(String path, Encoding encoding)
   at System.IO.File.ReadAllText(String path)
   at JsonFlatFileDataStore.DataStore.ReadJsonFromFile(String path)
   at JsonFlatFileDataStore.DataStore..ctor(String path, Boolean useLowerCamelCase, String keyProperty, Boolean reloadBeforeGetCollection)
   at Common.Database.DbClient..ctor(Configuration configuration) in /home/runner/work/peloton-to-garmin/peloton-to-garmin/src/Common/Database/DbClient.cs:line 27
   at PelotonToGarminConsole.Program.RunAsync(Configuration config) in /home/runner/work/peloton-to-garmin/peloton-to-garmin/src/PelotonToGarminConsole/Program.cs:line 120
   at PelotonToGarminConsole.Program.Main(String[] args) in /home/runner/work/peloton-to-garmin/peloton-to-garmin/src/PelotonToGarminConsole/Program.cs:line 93

Update Docker Image

Please update the docker image to use the new python requirements as my Garmin authenticating is failing and it seems like the docker image hasn't been updated to pull in the new requirements that were released to fix the issue.

Is there a way to read user settings?

If I switch to kilometers instead of miles, the result is going to be incorrect.

Is there a way to read the user settings before making the calculations?

Support runs (or ignore in the API pull)

Outdoor runs are exported as cycling activities. The metrics are off. Suggest a check for activity type, and ignore non-cycling for now. Nice to ultimately support all Peloton activities, but might require meaningful work.

In my spare time, I may tinker with supporting runs. Not a major personal priority at moment.

Peloton API Changed

Getting 404 from this query:

 /sample?every_n=1&fields=seconds_since_pedaling_start,power,cadence,speed,heart_rate,distance&limit=14400

Sample Fiddler output, think I might have to use this instead:

GET api.onepeloton.com/api/workout/809920519ff34474aad9a7c832bc2eb5/performance_graph?every_n=5 

Maybe consider pulling from Strava instead, api may be more stable.
https://developers.strava.com/

documentation planning for Python and OS versions

This isn't really request, so much as a couple of thoughts about documentation. I wasn't really sure where to put it.

At some point (I don't know if we are there yet), maybe it makes sense to pull some information out of the README and into separate docs. Some Linux versions, such as Ubuntu, have a new release every six months. I don't think it makes sense to keep the entire list in the README. Linux users are likely to know there way around GitHub to look in docs, and of course there can be a link from README to docs.

Upon my latest pull request, I noticed that it looks like ubuntu, windows, and mac all get automatic tests for python 3.5-3.8. Is that correct? This would be good information for the readme. Probably the ubuntu 3.5-3.8 test is enough. The real issue between Linux distros would be the python version, I would think.

System.InvalidOperationException: Process must exit before requested information can be determined.

2021-04-18 18:15:46.377 +00:00 [INF] Sleeping for 3600 seconds...
2021-04-18 18:17:28.759 +00:00 [INF] Encoded FIT file /app/working/20_min_Country_Ride_with_Olivia_Amato.fit
2021-04-18 18:17:29.048 +00:00 [INF] Encoded FIT file /app/working/20_min_2000s_Hip_Hop_Ride_with_Hannah_Corbin.fit
2021-04-18 18:17:32.444 +00:00 [INF] GUpload: 2021-04-18 18:17:29,254 [INFO] Try to login on GarminConnect...
2021-04-18 18:17:31,446 [INFO] Logged in as [email protected]
2021-04-18 18:17:31,892 [INFO] Uploaded activity 6630533736 : 20_min_Country_Ride_with_Olivia_Amato.fit
2021-04-18 18:17:32,424 [INFO] Uploaded activity 6630533774 : 20_min_2000s_Hip_Hop_Ride_with_Hannah_Corbin.fit
2021-04-18 18:17:32,425 [INFO] All done.

2021-04-18 18:17:32.447 +00:00 [ERR] Uncaught Exception.
System.InvalidOperationException: Process must exit before requested information can be determined.
at System.Diagnostics.Process.EnsureState(State state)
at System.Diagnostics.Process.get_ExitCode()
at Garmin.GarminUploader.UploadViaPython(String[] files) in /build/src/Garmin/GarminUploader.cs:line 106
at Garmin.GarminUploader.UploadToGarmin() in /build/src/Garmin/GarminUploader.cs:line 50
at PelotonToGarminConsole.Program.RunAsync(Configuration config) in /build/src/PelotonToGarminConsole/Program.cs:line 125
at PelotonToGarminConsole.Program.Main(String[] args) in /build/src/PelotonToGarminConsole/Program.cs:line 84

Suspect this recent change may be the culprit.

Total Work not uploading correctly

Hi,
I've noticed on my last few rides that the total work is not uploading correctly to Garmin. I'm not sure if it is just me or others are having this problem. I had this problem a few months ago and updating to the latest version seemed to fix the issue, but it started occurring again in the last week.

Here is an example of my ride.
https://connect.garmin.com/modern/activity/embed/5637509450

Here you can see the total work as 358 kJ but the ride should actually be 394 kJ according to the Peloton bike. If you do the math, an average power of 146W would be 394 kJ as well.

Just started failing Garmin user login

This is awesome and has worked for several weeks but started failing a few days ago. Using same creds as defined in config.ini work at connect.garmin.com just fine. But I get the error below when using the tool.

What am I doing wrong?

021-01-12 11:45:47,629 - INFO - peloton-to-garmin: Get latest 1 workouts.
2021-01-12 11:45:47,735 - INFO - peloton-to-garmin: Get workout: d87781e990a94724ac03dcc43b22a387
2021-01-12 11:45:47,968 - INFO - peloton-to-garmin: Get workout samples
2021-01-12 11:45:48,582 - INFO - peloton-to-garmin: Get workout summary
2021-01-12 11:45:50,764 - INFO - peloton-to-garmin: Writing TCX file: 1610378762-45 min 90s Ride with Emma Lovewell-d87781e990a94724ac03dcc43b22a387.tcx
2021-01-12 11:45:50,765 - INFO - peloton-to-garmin: Queing activity for upload: 45 min 90s Ride with Emma Lovewell
2021-01-12 11:45:50,766 - INFO - peloton-to-garmin: Uploading activities to Garmin...
2021-01-12 11:45:53,560 [CRITICAL] Login Failure: Login check failed.
Traceback (most recent call last):
File "peloton-to-garmin.py", line 95, in
PelotonToGarmin.run(config)
File "peloton-to-garmin.py", line 82, in run
raise e
File "peloton-to-garmin.py", line 79, in run
garminUploader.uploadToGarmin(garminUploadHistoryTable)
File "/data/programs/peloton-to-garmin/lib/garminClient.py", line 29, in uploadToGarmin
assert self.user.authenticate(), "Failed to authenticate garmin user."
AssertionError: Failed to authenticate garmin user.

Garmin Upload failed

The garmin upload feature works fine until it hits the attached workout. Appears to be 25th? one.
Logging info is below.

2020-12-11 10:26:57,371 - INFO - peloton-to-garmin: Writing TCX file: 1606521052-5 min Post-Ride Stretch with Denis Morton-668e3487167f40779aae809ee412d775.tcx
2020-12-11 10:26:57,371 - INFO - peloton-to-garmin: Workout already uploaded to garmin, skipping...
2020-12-11 10:26:57,372 - INFO - peloton-to-garmin: Get workout: 86e1f383b2164f3392ac4ec6f10d7a56
2020-12-11 10:26:57,824 - INFO - peloton-to-garmin: Get workout samples
2020-12-11 10:26:58,396 - INFO - peloton-to-garmin: Get workout summary
2020-12-11 10:26:58,954 - INFO - peloton-to-garmin: Writing TCX file: 1606519184-30 min Power Zone Ride with Denis Morton-86e1f383b2164f3392ac4ec6f10d7a56.tcx
2020-12-11 10:26:58,955 - INFO - peloton-to-garmin: Uploading workout to Garmin
2020-12-11 10:26:59,500 [CRITICAL] Login Failure: Authentification failed.
2020-12-11 10:26:59,502 - ERROR - peloton-to-garmin.garminClient: Failed to upload to Garmin Connect. - Invalid credentials
2020-12-11 10:26:59,502 - ERROR - peloton-to-garmin: Failed to upload to Garmin: Invalid credentials
2020-12-11 10:26:59,503 - INFO - peloton-to-garmin: Get workout: b3150dd5f21142d586c03c940379651b
2020-12-11 10:26:59,876 - INFO - peloton-to-garmin: Get workout samples
2020-12-11 10:27:00,426 - INFO - peloton-to-garmin: Get workout summary
2020-12-11 10:27:01,018 - INFO - peloton-to-garmin: Writing TCX file: 1606422414-30 min Power Zone Classic Rock Ride with Olivia Amato-b3150dd5f21142d586c03c940379651b.tcx
2020-12-11 10:27:01,018 - ERROR - peloton-to-garmin: Failed to upload to Garmin: I/O operation on closed file.

1606519184-30 min Power Zone Ride with Denis Morton-86e1f383b2164f3392ac4ec6f10d7a56.txt

[FeatureRequest] Support to Upload by date instead of last # activities

For users who run this script as a scheduled task or job, would be easier for the script to attempt fetch all activities since a LastSyncDate. Now that we have a simple database to work with, this is more feasible.

While the above is true, I'm not ready to do this yet. There are a couple challenges with implementing this for the Console app, the biggest being how to handle if the user needs "reset" the last sync date in cases where the sync failed.

For now will focus on the API and UI experience:

  • Home page should now display today's workouts
  • Home page Sync button should default to syncing today's workouts

Update 8/22
Peloton api now seems to support querying workouts by date, which is great!

https://api.onepeloton.com/api/user/9d50dddf7e594c57bda54280eeec98d7/workouts?to=2022-08-04T00%3A08%3A20.120Z&from=2022-07-04T05%3A00%3A00.000Z&stats_to=2022-08-04T00%3A08%3A20.120Z&stats_from=2022-07-04T05%3A00%3A00.000Z&joins=ride
  • Decide if api/peloton/workouts/sinceDate is the final route
  • Unit Tests
  • Regression Sync
  • Regression Console

Python Package Github Workflow tags incorrectly

Currently the workflow is not tagging the latest commit. This is because the workflow itself creates a new commit (the windows distro for that release) but the version bump action uses the original commit sha that triggered the job. Probably makes sense to split these workflows into

  1. Package - creates a windows distro and commits to Master
  2. Release - version up, tag, upload artifacts to release

TCX files not uploading to Garmin

Ever since the API problem about two weeks ago, I haven't been able to get my TCX files to automatically upload to Garmin after running the script. Any ideas? Thanks!

Not reading ini file

I ran the docker and tried using the ini file rather than the env vars. It appears to accept some like the peloton login, but it seems to ignore most of the rest. It didn't upload to garmin or accept the poll interval despite it being set and uncommented in the ini. Any ideas?

Unit Tests

Even a couple would be helpful. But I'm not familiar with unit testing in python.

Run polling in a loop that doesn't get stopped by user input

Love the tool but I'd love to see a small enhancement with polling.

The current behavior with polling runs in a loop but gets stopped by "Press the key to continue...". It stops here until obviously you hit enter and it does another loop.

Desired behavior: Using polling you are not stopped by this user input step. Polling runs on interval specified, does what it needs to do and then sleeps until the next interval.

Screenshot 2021-04-14 123508

"Workout already uploaded to Garmin", but I deleted all workouts after changing the "upload enabled=true"

I have to say great thing you are doing here! Thanks so much!!

I wanted to upload all 287 rides from peloton to Garmin Connect.
I first did it manually, I noticed that the workout title is "Cycling" however when uploaded is enabled for automatically upload to Garmin, the Peloton class title is listed, like "Top 50 of 2020 (#40 - 31) with Leanne Hainsby"
Also a manual upload shows 'Cycling' compared to automatic upload as "Indoor Cycling"

I did not notice the "upload enabled" option until I manually uploaded the 287 rides. I then deleted all of them from Garmin connect and now tried around 30 and it keeps saying "Workout already uploaded to Garmin"

Timezone Incorrect

Also noticed that with the old v1 container it was in my timezone, that is the log file and the uploads to Garmin, with v2 it seems to be all in UTC.. I tried setting the following in the compose file, but not sure the image is using tzdata

environment:

  • "TZ=America/New_York"

Unable to upload to Garmin

Using latest windows binary. Today it stopped uploading to Garmin. No errors show up in log. Thanks for checking.

Files are attached that I attempted to upload incase that is the issue.

Output.zip

Side note, Queing is spelled wrong in log :-)

Log records from yesterday
2021-02-22 13:08:18,224 - INFO - peloton-to-garmin: Uploading activities to Garmin...
2021-02-22 13:08:22,072 - INFO - peloton-to-garmin.garminClient: Uploaded activity: 5 min Post-Ride Stretch with Denis Morton
2021-02-22 13:08:24,559 - INFO - peloton-to-garmin.garminClient: Uploaded activity: 45 min Power Zone Ride with Denis Morton
2021-02-22 13:08:24,559 - INFO - peloton-to-garmin: Done!

Today
2021-02-23 14:18:18,894 - INFO - peloton-to-garmin: Queing activity for upload: 60 min Power Zone Ride with Matt Wilpers
2021-02-23 14:18:18,894 - INFO - peloton-to-garmin: Uploading activities to Garmin...

Failed to Login to Peloton - Causes Crash

Seems that Peloton has shut down the previous endpoint this tool used to sign in. Will take some work to find a replacement endpoint.... if one even exists.

2021-01-25 12:55:57,750 - DEBUG - peloton-to-garmin.PelotonApi: <Response [404]>
File "peloton-to-garmin.py", line 95, in <module>
    PelotonToGarmin.run(config)
  File "peloton-to-garmin.py", line 27, in run
    pelotonClient = pelotonApi.PelotonApi(config.peloton_email, config.peloton_password)
  File "G:\Code\Git\peloton-to-garmin\lib\pelotonApi.py", line 25, in __init__
    parsed_response = util.parse_response(response)
  File "G:\Code\Git\peloton-to-garmin\lib\util.py", line 21, in parse_response
    parsed_response = json.loads(response.text)
  File "C:\Users\Bailey\AppData\Local\Programs\Python\Python36-32\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Bailey\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Bailey\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Serverless setup?

What do you think of moving the setup from the docker to serverless/lambda functions?
I'm thinking of the best way to automate the process but stick to a free cloud plan.

Basically, I can trigger the import automatically by calling the API provided by lambdas.

Support Expanded Activity Types in Garmin TCX

Reported by @clipin

Cycling workouts are categorized "Cycling", suggest "Indoor Cycling".

Stretching is categorized as "Other". Suppose that's fine? Or we can create a mapping of Peloton Activity Type = Garmin Activity Type? Tapiriik's mappings are here.

The default TCX schema does not support the expanded Activity types. I suspect we need to include additional schema definitions (example) in order to get the extra activity types to work properly.

Garmin auth failed in docker after a few hours

I get this log output

INFO:peloton-to-garmin:Uploading activites to Garmin...
[CRITICAL] Login Failure: Authentification failed

When I launch the docker container, it works fine. Fetches my number of activities 6 and uploads them to Garmin.

I haven't timed it exactly but it seems like the original auth to garmin times out at some point, and eventually the python script finds a new workout from Peloton to upload, but by that point the auth token is expired.

I have it setup in a docker container on my NAS to just run and check for updates every 10 minutes. It seems like the auth to garmin connect happens when the script runs initially, but what if you authed right before upload each time and then destroyed the garminUploader instance until you next need to upload?

Tool downloads in progress workouts

I have a cron job set up and if it runs while I'm working out it will download the partial workout. Is there some sort of flag to detect when the activity is finished?

Support proper power zones from Peloton

At the moment, if you don't own a power zone-enabled Garmin device, you have no way of setting your FTP on your GC account; when you get your Peloton workout data into Garmin, the power zone graph will be wildly incorrect. Is there a way to include FTP info on the activities?

Prepped fit file - Uncaught Exception

Attempting to upload a Peloton workout to Garmin, and getting

[11:25:10 DBG] Prepped fit file ./working\upload\30_min_80s_Ride_with_Hannah_Frankson.fit for upload.
[11:25:10 ERR] Uncaught Exception.
System.NullReferenceException: Object reference not set to an instance of an object.
at Conversion.Converter`1.GetTitle(Workout workout) in /home/runner/work/peloton-to-garmin/peloton-to-garmin/src/Conversion/IConverter.cs:line 274
log20210430.txt
30_min_80s_Ride_with_Hannah_Frankson.zip

Running v2 windows executable. I was able to successfully upload workouts prior to this error.

Update Dockerfile

Dockerfile has fallen behind, needs to be updated to handle the more recent config values this script now supports. I am not setup to test or run docker, so seeking help from someone in the community to update and verify its working.

Garmin Upload - Authentication Error

Has anyone started encountering this issue recently? I have had this running without any issues for about 1.5 weeks and randomly overnight I started getting this issue below even though the password and everything is correct and I havent changed any settings.

`2021-01-06 03:23:47,402 [CRITICAL] Login Failure: Authentification failed.

Traceback (most recent call last):

File "/opt/app/peloton-to-garmin.py", line 158, in

PelotonToGarmin.run(config)

File "/opt/app/peloton-to-garmin.py", line 86, in run

raise e

File "/opt/app/peloton-to-garmin.py", line 83, in run

garminUploader.uploadToGarmin(garminUploadHistoryTable)

File "/opt/app/lib/garminClient.py", line 29, in uploadToGarmin

assert self.user.authenticate(), "Failed to authenticate garmin user."

AssertionError: Failed to authenticate garmin user.`

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.