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

Provide error message if speed is not target #23

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions trainaspower/trainasone.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def get_workout(workout_url: str, date: datetime.date, config: models.Config) ->
def convert_steps(steps, config: models.Config, perceived_effort: bool) -> Generator[models.Step, None, None]:
recovery_step_types = ["REST", "RECOVERY", "COOLDOWN"]
active_step_types = ["ACTIVE", "INTERVAL"]
valid_target_types = ["OPEN", "SPEED"]
for step in steps:
if step["type"] == "WorkoutRepeatStep":
times = int(step["repeatValue"])
Expand All @@ -125,6 +126,10 @@ def convert_steps(steps, config: models.Config, perceived_effort: bool) -> Gener
if "description" in step:
out_step.description = step["description"]

if not step["targetType"] in valid_target_types:
raise ValueError(
f"Unsupported target type {step['targetType']}. Please ensure that you have selected speed as \"Workout step target\" in the TAO settings under \"Garmin workout preferences\"")

if step["intensity"] == "WARMUP":
out_step.type = "WARMUP"
elif step["intensity"] in active_step_types:
Expand Down