Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strava upload #268

Merged
merged 5 commits into from
Feb 8, 2021
Merged

Strava upload #268

merged 5 commits into from
Feb 8, 2021

Conversation

soutade
Copy link
Contributor

@soutade soutade commented Feb 6, 2021

Strava upload scripts (bash & Python) in tools directory without use of submodules.
Need more work for a deeper integration in project (libambit and/or GUI).

@centic9
Copy link
Contributor

centic9 commented Feb 8, 2021

When I try to run it from withing openambit-source-code I get the following:

± ./strava_upload.sh
..//tools/openambit2gpx.py /home/<user>/.openambit/log_81B2F9530B001A00_2021_02_07_08_41_09.log /opt/openambit/openambit.git/tools/gpx/log_81B2F9530B001A00_2021_02_07_08_41_09.gpx
Traceback (most recent call last):
  File "..//tools/openambit2gpx.py", line 35, in <module>
    fOut=open(fileOut, 'w')
FileNotFoundError: [Errno 2] No such file or directory: '/opt/openambit/openambit.git/tools/gpx/log_81B2F9530B001A00_2021_02_07_08_41_09.gpx'
..//tools/stravauploader/strava_uploader.py -l /opt/openambit/openambit.git/tools/gpx/log_81B2F9530B001A00_2021_02_07_08_41_09.gpx
Process /opt/openambit/openambit.git/tools/gpx/log_81B2F9530B001A00_2021_02_07_08_41_09.gpx
Traceback (most recent call last):
  File "..//tools/stravauploader/strava_uploader.py", line 134, in <module>
    uploadMoves(args.logs)
  File "..//tools/stravauploader/strava_uploader.py", line 110, in uploadMoves
    (status_code, status) = uploadMove(activity)
  File "..//tools/stravauploader/strava_uploader.py", line 80, in uploadMove
    files = {'file': open(activity, 'rb')}
FileNotFoundError: [Errno 2] No such file or directory: '/opt/openambit/openambit.git/tools/gpx/log_81B2F9530B001A00_2021_02_07_08_41_09.gpx'

Seems the mkdir did not work for me for some reason...

I was starting the .sh with the current directory in the "tools" directory.

@soutade
Copy link
Contributor Author

soutade commented Feb 8, 2021

Fixed. I didn't see it because I launched it from ${ROOT} and not tools. Sorry.

@centic9 centic9 merged commit 2802e5e into openambitproject:master Feb 8, 2021
@centic9
Copy link
Contributor

centic9 commented Feb 8, 2021

Thanks for the contribution, it did work now for me with a few test-uploads!

I am not sure how I will handle my Moves when movescount finally shuts down, I will take a look at this then for sure, maybe it is something that we can build out into the "main" way of downloading and publishing moves in the future.

@soutade
Copy link
Contributor Author

soutade commented Feb 8, 2021

You're welcome !
The hard thing with Strava is to configure their credentials (which requires update every ~24 hours).
It's hard to find a good replacement for movescount. Garmin one is pretty good, but they have a closed platform and activities needs to be imported by hand.
From my experience, Strava is a good alternative (presentation + API), but if there is a better one I would be happy to know it !

@marguslt
Copy link

marguslt commented Feb 8, 2021

From my experience, Strava is a good alternative (presentation + API), but if there is a better one I would be happy to know it !

Not sure about "better" , but Runalyze is definitely one worth checking out, they even provide Personal API.
And of course there's self-hosted https://github.com/bwaldvogel/openmoves

@soutade
Copy link
Contributor Author

soutade commented Feb 8, 2021

Sure. I also tested it and it better handles all metrics, but the web interface is really ugly (personal point of view). They really need to do a lot of work on it before it'll be usable for all public.

@Gerold-R
Copy link

@marguslt
Do you know https://quantified-self.io?

@marguslt
Copy link

@Gerold-R , yes, though I personally prefer Runalyze over it, QS provides some really nice and unique features. Not sure about upload API.

@Gerold-R
Copy link

@marguslt
I just created an account and there is an upload button for JSON GPX TCX FIT and SML files.
A friend of mine has just started programming in Python and he has created his first program which reads the logbook of an Ambit watch via WebSocket from the SDSApplicationServer. The program is also able to save a workout as JSON and GPX. I just used it to save a workout. The JSON file was not accepted by QS, but the GPX was. I started the py program using PyCharm on Linux Mint 20.1 and the SDSApplicationServer.exe with Wine 6.1 dev. Will try to get more information about the JSON format needed for QS.
BTW:
There are also buttons to upload FIT files or routes into the Suunto App

@marguslt
Copy link

@Gerold-R , not saying you can't upload or automate through QS upload form, just that as far as I know, QS currently does not provide an upload interface in API-form.

JSON for QS - It expects the samples.json that is sent to Suunto App service by mobile app,
so those files are only generated if watches is synced through Suunto App (i.e. models with bluetooth), files are user-accessible (<Internal Storage>/Android/data/com.stt.suunto/files/smlzip/ ) and include pretty much the same data that was included in Moveslink2 SML files. The JSON structure that is sent out by Suuntolink is different, at least for Ambits, so if its really the SDSApplicationServer that handles JSON serialization, that output would not work with QS.

You can reverse the actual JSON structure by going through the importer QS is using for that - https://github.com/sports-alliance/sports-lib/tree/develop/src/events/adapters/importers/suunto .
And/or check some other stand-alone parser like https://github.com/mrvdb/suuntoapp2gpx

BTW, going through that Python websocket client for SDSApplicationServer would be quite interesting for me, if you guys decide to make it public it at some point or just share privately, feel free ping me.

@Gerold-R
Copy link

@marguslt
No problem for the Python script. Maybe the script can be written better as he just started learning Python. At least the events from the server to client are not handled. In our sync tool for Linux build with Lazarus this is done of course.

I uploaded the script to my Google Drive account together with some other tools we shared:
https://drive.google.com/drive/folders/1sZ6sIlQVfwEbOjtQXO3PJJ7PtMy2wTQe?usp=sharing

You can also update the SGEE data with the script or sync an Ambit, but as I said, the event handler is not implemented yet.

JSON structure:
Unfortenatly since I removed Moveslink and installed Suunto App on my iPhone, the App has never detected my Ambit. Even after I reinstalled lastest iOS. I will have a look at the importer. This is the same Elevate for Strava is using, right?

QS:
No, there exists no import API yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants