Skip to content

Commit 7b79137

Browse files
committed
Adding demo after adding README
1 parent db32ea1 commit 7b79137

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

demo.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@ def __init__(self):
366366
"desc": "Track gear usage (total time used)",
367367
"key": "track_gear_usage",
368368
},
369+
"7": {
370+
"desc": "Add and remove gear to/from activity (interactive)",
371+
"key": "add_and_remove_gear_to_activity",
372+
},
369373
},
370374
},
371375
"0": {
@@ -2394,6 +2398,58 @@ def set_gear_default_data(api: Garmin) -> None:
23942398
print(f"❌ Error setting gear default: {e}")
23952399

23962400

2401+
def add_and_remove_gear_to_activity(api: Garmin) -> None:
2402+
"""Add gear to most recent activity, then remove."""
2403+
try:
2404+
device_last_used = api.get_device_last_used()
2405+
user_profile_number = device_last_used.get("userProfileNumber")
2406+
if user_profile_number:
2407+
gear_list = api.get_gear(user_profile_number)
2408+
if gear_list:
2409+
activity = api.get_activities(0, 1)[0]
2410+
activity_id = activity.get("activityId")
2411+
activity_name = activity.get("activityName")
2412+
for gear in gear_list:
2413+
if gear["gearStatusName"] == "active":
2414+
break
2415+
gear_uuid = gear.get("uuid")
2416+
gear_name = gear.get("displayName", "Unknown")
2417+
if gear_uuid:
2418+
# Add gear to an activity
2419+
# Correct method signature: add_gear_to_activity(gearUUID, activity_id)
2420+
call_and_display(
2421+
api.add_gear_to_activity,
2422+
gear_uuid,
2423+
activity_id,
2424+
method_name="add_gear_to_activity",
2425+
api_call_desc=f"api.add_gear_to_activity('{gear_uuid}', {activity_id}) - Add {gear_name} to {activity_name}",
2426+
)
2427+
print("✅ Gear added successfully!")
2428+
2429+
# Wait for user to check gear, then continue
2430+
input("Go check Garmin to confirm, then press Enter to continue")
2431+
2432+
# Remove gear from an activity
2433+
# Correct method signature: remove_gear_from_activity(gearUUID, activity_id)
2434+
call_and_display(
2435+
api.remove_gear_from_activity,
2436+
gear_uuid,
2437+
activity_id,
2438+
method_name="remove_gear_from_activity",
2439+
api_call_desc=f"api.remove_gear_from_activity('{gear_uuid}', {activity_id}) - Remove {gear_name} from {activity_name}",
2440+
)
2441+
print("✅ Gear removed successfully!")
2442+
2443+
else:
2444+
print("❌ No gear UUID found")
2445+
else:
2446+
print("ℹ️ No gear found")
2447+
else:
2448+
print("❌ Could not get user profile number")
2449+
except Exception as e:
2450+
print(f"❌ Error adding gear: {e}")
2451+
2452+
23972453
def set_activity_name_data(api: Garmin) -> None:
23982454
"""Set activity name."""
23992455
try:

0 commit comments

Comments
 (0)