openambitproject / openambit

openambit
277 stars 82 forks source link

Enhancement: Structured Workouts Sync #257

Open dgvalde opened 3 years ago

dgvalde commented 3 years ago

It would be very useful to have also the possibility to extract information about Structured Workouts from the Ambit watch.

Well those are not available at Movescount and only done with the smartphone app. But one could download the files containing the information about the structured workouts from the watch, then manually modify them, and push them back to the Ambit watch.

This feature would be very much appeciated when Movescount says goodbye.

P.D: I could help develop this if I get some help to get started (while I have experience on coding I do not have much on linux development)

centic9 commented 3 years ago

Hi, thanks for the suggestion and for the offer, while I don't know much about "structured workouts", I only have an Ambit 2 which may not have this functionality, so I cannot be of much help in development/testing, but I can give some initial instructions of how to get started with development.

The cmake tool is fairly easy to use and a recent version of Ubuntu or Debian usually works quite well as development platform.

I suggest you follow the sections "Requirements" and "Build Procedure" in the README at https://github.com/openambitproject/openambit/blob/master/README.rst, let me know if you run into problems so I can enhance/update the instructions if necessary.

If you can describe the functionality some more I can then give some hints as to where you could start to add stuff in the source code.

marguslt commented 3 years ago

But one could download the files containing the information about the structured workouts from the watch, then manually modify them, and push them back to the Ambit watch.

Just a quick note about Workouts - while Movescount app provides Workout builder interface, Workouts are actually managed and stored by Movescount service. MC mobile app generates a JSON describing the workout, sends it to MC service which compiles it into binary blob which in turn is stored in the watch by MC mobile app. Currently you don't actually need to read out Workout from the watch, you could retrieve existing Workouts from from Movescount service instead, it provides you with both binary and JSON. You can also alter the JSON yourself and send your newly modified Workout to Movescount service for compilation and storage.

BTW, Movescount mobile app is not the only piece syncing those Workouts, activated Workouts are also transferred to the watch if you sync with a cable and Moveslink2 or Suuntolink ( Suunto now urges Ambit owners to use Suuntolink instead of Moveslink2).

Here's a demo of adding a new Workout and adjusting the list of activated Workouts without MC app - https://gist.github.com/marguslt/a79ea204f99b45ab015b6ed1ff7529a4

Currently there's no telling if and for how long Workout support in service itself will remain, but for at least few months there shouldn't be any change as cut-off for Movescount mobile apps and Moveslink2 was just postponed:

https://www.suunto.com/Content-pages/suuntos-digital-services/ We have decided, in order to ensure the best possible consumer experience for all our community, that we will postpone the planned changes to Movescount App, SuuntoLink, and Moveslink2 until 2021.

dgvalde commented 3 years ago

Many thanks @marguslt for your help. Indeed you are right and your little demo is all I was looking for to get going for now.

Inspired on your demo I have created very simple scripts to download and push workout files to Movescount https://gist.github.com/dgvalde/4bb9a9dc2162c27440a978b217c01b7e

For those trainning with power, this method lets you select specific power zones as target (since the Movescount app only lets you select power zones on increments of hundreds of watts) Here below I provide an example of a workout based on power with specific power zones: https://gist.github.com/dgvalde/9e00a590388224122bd7d295f886bced

Thanks to both of you.

myadzel commented 3 years ago

Tell me, where can I see these structured workouts?

I did't find on Movescount web. I did't find in Movescount app (for Android).

But as a result of the execution of the list_ambit_workouts.sh and then download_workout.sh, I get the following content:

{
  "name": "My Workout",
  "steps": [
    {
      "duration": {
        "durationName": "time",
        "value": 600
      },
      "target": {
        "targetName": "hr",
        "valueRange": {
          "max": 2.1666666666666665,
          "min": 2
        }
      },
      "text": "Easy jogging",
      "type": {
        "typeName": "warmup"
      }
    },
    {
      "type": {
        "typeName": "repeatStart",
        "value": 3
      }
    },
    {
      "duration": {
        "durationName": "distance",
        "value": 1000
      },
      "target": {
        "targetName": "pace",
        "valueRange": {
          "max": 0.25,
          "min": 0.27
        }
      },
      "text": "Run fast for 1km",
      "type": {
        "typeName": "interval"
      }
    },
    {
      "duration": {
        "durationName": "hr_below",
        "value": 2.1666666666666665
      },
      "target": {
        "targetName": "none",
        "valueRange": {
          "max": 0,
          "min": 0
        }
      },
      "text": "Walk to recover",
      "type": {
        "typeName": "recovery"
      }
    },
    {
      "type": {
        "typeName": "repeatEnd"
      }
    },
    {
      "duration": {
        "durationName": "time",
        "value": 600
      },
      "target": {
        "targetName": "hr",
        "valueRange": {
          "max": 1.8333333333333333,
          "min": 1.3333333333333333
        }
      },
      "text": "Walk to cool down",
      "type": {
        "typeName": "cooldown"
      }
    }
  ],
  "workoutDescription": "Basic running workout"
}

It looks like some kind of stub for given service (uiservices.movescount.com/rules/{id}).

dgvalde commented 3 years ago

Hi Alexander (@myadzel)

I guess it depends on which watch you own. I have a Suunto Ambit 3 Peak and I can only see the structured workouts on the Android Movescout application. Nothing on the Movescount web. (This is why I originally thought that this information was only avaialble locally on the Android app and not synced on the server, but I was wrong).

If your watch supports structured workouts (or trainnings) once you sync your phone with your watch on Movescount you will get a settings windows which lets you change the configuration of your watch: Sports modes, Settings and Workouts.

As an example on how the screen looks like see this thread in Reddit which seems funnily enough to be created by @marguslt, who gave the hint on how this works previously. :-D

dgvalde commented 3 years ago

@marguslt, where you able to create structured workouts on the Suunto 9?

marguslt commented 3 years ago

@dgvalde , those screenshots are indeed mine, originally posted to forum.suunto.com (or maybe facebook, can't recall), but that reddit thread is by someone else. Anyway, I'd say no - workouts are only available for Ambit3.