-
-
Notifications
You must be signed in to change notification settings - Fork 347
Open
Description
Bug
The TargetType class in garminconnect/workout.py has an incorrect constant for heart rate:
class TargetType:
NO_TARGET = 1
HEART_RATE = 2 # ← this is wrong
CADENCE = 3
SPEED = 4
POWER = 5
OPEN = 6Using TargetType.HEART_RATE (value 2) when building a workout step results in Garmin storing the target as power zone (workoutTargetTypeKey: "power.zone"), not heart rate.
Steps to reproduce
from garminconnect.workout import ExecutableStep, TargetType
step = ExecutableStep(
stepOrder=1,
stepType={"stepTypeId": 3, "stepTypeKey": "interval", "displayOrder": 3},
endCondition={"conditionTypeId": 2, "conditionTypeKey": "time", "displayOrder": 2, "displayable": True},
endConditionValue=300.0,
targetType={
"workoutTargetTypeId": TargetType.HEART_RATE, # value = 2
"workoutTargetTypeKey": "heart.rate.zone",
"displayOrder": 2,
},
targetValueOne=120,
targetValueTwo=150,
)After uploading and fetching back via get_workout_by_id(), Garmin returns:
"targetType": {
"workoutTargetTypeId": 2,
"workoutTargetTypeKey": "power.zone"
}Fix
Garmin's actual target type ID for heart rate zones is 4, not 2. The correct constants should be:
class TargetType:
NO_TARGET = 1
POWER = 2 # power.zone
CADENCE = 3 # cadence
HEART_RATE = 4 # heart.rate.zone
SPEED = 5 # speed.zone
OPEN = 6 # openUsing workoutTargetTypeId: 4 with workoutTargetTypeKey: "heart.rate.zone" produces the correct result verified by fetching the workout back from the API.
Environment
garminconnectversion: 0.2.40- Python: 3.14.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels