Sports Tracker v2.0
Track P90X workouts, cycling, hiking, running with SQLite, CLI reports, automatic calorie calculation, and automated Komoot tour import.
Features
- Manual Logging - Log activities via CLI with automatic calorie calculation
- Automated Komoot Import - Fetches and imports tours automatically (every 4h)
- Auto-Calorie Calculation - Based on MET × weight × duration
- Workout Tracking - Training day management (Mon/Wed/Fri)
- GPX Export - Download GPX data from Komoot tours
- Multi-format Reports - Weekly, monthly, detailed stats
- Dedup - Prevents duplicate imports via Komoot tour ID
CLI Usage
# Initialize / migrate database (safe to run on existing DB)
python3 skills/sports-tracker/scripts/sports_tracker.py --init
# ─── Add activities (auto-calculates calories) ───
python3 skills/sports-tracker/scripts/sports_tracker.py --add "5 km Wandern"
python3 skills/sports-tracker/scripts/sports_tracker.py --add "P90X"
python3 skills/sports-tracker/scripts/sports_tracker.py --add "P90X 45 min"
python3 skills/sports-tracker/scripts/sports_tracker.py --add "17.7 km Fahrrad"
python3 skills/sports-tracker/scripts/sports_tracker.py --add "5 km Wandern gestern"
# ─── Weight management ───
python3 skills/sports-tracker/scripts/sports_tracker.py --weight 115
# ─── Reports ───
python3 skills/sports-tracker/scripts/sports_tracker.py --week
python3 skills/sports-tracker/scripts/sports_tracker.py --month
python3 skills/sports-tracker/scripts/sports_tracker.py --month-full
python3 skills/sports-tracker/scripts/sports_tracker.py --list
python3 skills/sports-tracker/scripts/sports_tracker.py --stats
# ─── Workout Tracking (P90X) ───
python3 skills/sports-tracker/scripts/sports_tracker.py --done
python3 skills/sports-tracker/scripts/sports_tracker.py --done P90X3
python3 skills/sports-tracker/scripts/sports_tracker.py --missed
python3 skills/sports-tracker/scripts/sports_tracker.py --workout-status
python3 skills/sports-tracker/scripts/sports_tracker.py --workout-check
python3 skills/sports-tracker/scripts/sports_tracker.py --workout-stats
# ─── Komoot Import ───
python3 skills/sports-tracker/scripts/komoot_import.py
python3 skills/sports-tracker/scripts/komoot_import.py --full
python3 skills/sports-tracker/scripts/komoot_import.py --dry-run
python3 skills/sports-tracker/scripts/komoot_import.py --export-gpx
Categories
| Category |
Value type |
Type |
Emoji |
| P90X |
done (session count) |
strength |
💪 |
| Fahrrad |
km |
cardio |
🚴 |
| Spazieren |
km |
cardio |
🥾 |
| Laufen |
km |
cardio |
🏃 |
Calorie Calculation (Automatic)
Formula: Kcal = MET × weight_kg × duration_hours
| Activity |
MET |
Speed |
Duration Calculation |
| Fahrrad |
8.0 |
18 km/h |
km / 18 hours |
| Wandern |
3.5 |
4.5 km/h |
km / 4.5 hours |
| P90X |
6.0 |
— |
60 min (default) or specified |
Default weight: 120 kg (configurable via --weight)
Komoot Import Details
The komoot_import.py script connects to the Komoot API and imports tours into the sports tracker database.
What gets imported
- Distance in km
- Duration in minutes
- Calories via MET formula
- Elevation gain/loss in meters
- Average and max speed
- Sport type mapped to tracker categories
Komoot Sport-Type Mapping
| Komoot Type |
Sports Tracker |
| touring_cycling, cycling, mtb, race_cycling |
Fahrrad |
| hiking, hike |
Spazieren |
| walking, walk, nordic_walking |
Wandern |
| running, run, trail_running |
Laufen |
| skiing, ski_touring, snowboard |
Skifahren |
Setup
Add to .env:
KOMOOT_EMAIL=your@email.com
KOMOOT_PASSWORD=your_password
KOMOOT_USER_ID=your_user_id
Database
Path: data/sports_tracker.db
Tables
activities (main tracking)
| Column |
Type |
Description |
| id |
INTEGER |
Primary key |
| date |
TEXT |
Activity date |
| category |
TEXT |
Activity category |
| value |
TEXT |
km or "done" |
| description |
TEXT |
Activity description |
| created_at |
TEXT |
Timestamp |
| type |
TEXT |
'cardio' or 'strength' |
| duration_min |
INTEGER |
Duration in minutes |
| calories |
INTEGER |
Calculated calories |
| speed_kmh |
REAL |
Average speed |
| weight_kg |
REAL |
Weight at time of activity |
workout_status (P90X tracking)
| Column |
Type |
Description |
| date |
TEXT |
Unique date |
| is_training_day |
BOOLEAN |
Mo/We/Fr = true |
| status |
TEXT |
done, missed, rest, pending |
| type |
TEXT |
P90X, P90X2, P90X3 |
| notes |
TEXT |
Notes |
user_settings (key/value store)
| Key |
Default |
Description |
| weight_kg |
120 |
Current weight |
Workout Rules
- Training days: Monday, Wednesday, Friday
- Rest days: Tuesday, Thursday, Saturday, Sunday
- "done" on training day or next day = counted as trained
- Sarcasm trigger: 2+ missed training days in last 14 days
Date Parsing
Recognizes German phrases:
heute → today
gestern → yesterday
vorgestern → day before yesterday
DD.MM.YYYY → explicit date
Migration
--init safely migrates existing v1 databases to v2 without data loss:
- Adds new columns (
type, duration_min, calories, speed_kmh, weight_kg)
- Creates
workout_status, workout_rules, and user_settings tables
- Preserves all existing activity data
1---2name: sports-tracker3description: Sport- und Fitness-Tracking mit P90X, Fahrrad, Wandern, Laufen. SQLite-basiert mit automatischem Komoot-Import, Berichten (Woche, Monat), Emoji-Visualisierung, Kalorien-Berechnung und Workout-Tracking.4---5
6# Sports Tracker v2.0
7
8Track P90X workouts, cycling, hiking, running with SQLite, CLI reports, automatic calorie calculation, and automated Komoot tour import.
9
10## Features
11
12- **Manual Logging** - Log activities via CLI with automatic calorie calculation
13- **Automated Komoot Import** - Fetches and imports tours automatically (every 4h)
14- **Auto-Calorie Calculation** - Based on MET × weight × duration
15- **Workout Tracking** - Training day management (Mon/Wed/Fri)
16- **GPX Export** - Download GPX data from Komoot tours
17- **Multi-format Reports** - Weekly, monthly, detailed stats
18- **Dedup** - Prevents duplicate imports via Komoot tour ID
19
20## CLI Usage
21
22```bash
23# Initialize / migrate database (safe to run on existing DB)
24python3 skills/sports-tracker/scripts/sports_tracker.py --init
25
26# ─── Add activities (auto-calculates calories) ───
27python3 skills/sports-tracker/scripts/sports_tracker.py --add "5 km Wandern"
28python3 skills/sports-tracker/scripts/sports_tracker.py --add "P90X"
29python3 skills/sports-tracker/scripts/sports_tracker.py --add "P90X 45 min"
30python3 skills/sports-tracker/scripts/sports_tracker.py --add "17.7 km Fahrrad"
31python3 skills/sports-tracker/scripts/sports_tracker.py --add "5 km Wandern gestern"
32
33# ─── Weight management ───
34python3 skills/sports-tracker/scripts/sports_tracker.py --weight 115
35
36# ─── Reports ───
37python3 skills/sports-tracker/scripts/sports_tracker.py --week
38python3 skills/sports-tracker/scripts/sports_tracker.py --month
39python3 skills/sports-tracker/scripts/sports_tracker.py --month-full
40python3 skills/sports-tracker/scripts/sports_tracker.py --list
41python3 skills/sports-tracker/scripts/sports_tracker.py --stats
42
43# ─── Workout Tracking (P90X) ───
44python3 skills/sports-tracker/scripts/sports_tracker.py --done
45python3 skills/sports-tracker/scripts/sports_tracker.py --done P90X3
46python3 skills/sports-tracker/scripts/sports_tracker.py --missed
47python3 skills/sports-tracker/scripts/sports_tracker.py --workout-status
48python3 skills/sports-tracker/scripts/sports_tracker.py --workout-check
49python3 skills/sports-tracker/scripts/sports_tracker.py --workout-stats
50
51# ─── Komoot Import ───
52python3 skills/sports-tracker/scripts/komoot_import.py
53python3 skills/sports-tracker/scripts/komoot_import.py --full
54python3 skills/sports-tracker/scripts/komoot_import.py --dry-run
55python3 skills/sports-tracker/scripts/komoot_import.py --export-gpx
56```
57
58## Categories
59
60| Category | Value type | Type | Emoji |
61|----------|-----------|------|-------|
62| P90X | done (session count) | strength | 💪 |
63| Fahrrad | km | cardio | 🚴 |
64| Spazieren | km | cardio | 🥾 |
65| Laufen | km | cardio | 🏃 |
66
67## Calorie Calculation (Automatic)
68
69Formula: `Kcal = MET × weight_kg × duration_hours`
70
71| Activity | MET | Speed | Duration Calculation |
72|----------|-----|-------|---------------------|
73| Fahrrad | 8.0 | 18 km/h | `km / 18` hours |
74| Wandern | 3.5 | 4.5 km/h | `km / 4.5` hours |
75| P90X | 6.0 | — | 60 min (default) or specified |
76
77**Default weight:** 120 kg (configurable via `--weight`)
78
79## Komoot Import Details
80
81The `komoot_import.py` script connects to the Komoot API and imports tours into the sports tracker database.
82
83### What gets imported
84
85- Distance in km
86- Duration in minutes
87- Calories via MET formula
88- Elevation gain/loss in meters
89- Average and max speed
90- Sport type mapped to tracker categories
91
92### Komoot Sport-Type Mapping
93
94| Komoot Type | Sports Tracker |
95|------------|---------------|
96| touring_cycling, cycling, mtb, race_cycling | Fahrrad |
97| hiking, hike | Spazieren |
98| walking, walk, nordic_walking | Wandern |
99| running, run, trail_running | Laufen |
100| skiing, ski_touring, snowboard | Skifahren |
101
102### Setup
103
104Add to `.env`:
105```bash
106KOMOOT_EMAIL=your@email.com
107KOMOOT_PASSWORD=your_password
108KOMOOT_USER_ID=your_user_id
109```
110
111## Database
112
113Path: `data/sports_tracker.db`
114
115### Tables
116
117**activities** (main tracking)
118
119| Column | Type | Description |
120|-------------|---------|-------------|
121| id | INTEGER | Primary key |
122| date | TEXT | Activity date |
123| category | TEXT | Activity category |
124| value | TEXT | km or "done" |
125| description | TEXT | Activity description |
126| created_at | TEXT | Timestamp |
127| type | TEXT | 'cardio' or 'strength' |
128| duration_min| INTEGER | Duration in minutes |
129| calories | INTEGER | Calculated calories |
130| speed_kmh | REAL | Average speed |
131| weight_kg | REAL | Weight at time of activity |
132
133**workout_status** (P90X tracking)
134
135| Column | Type | Description |
136|--------|------|-------------|
137| date | TEXT | Unique date |
138| is_training_day | BOOLEAN | Mo/We/Fr = true |
139| status | TEXT | done, missed, rest, pending |
140| type | TEXT | P90X, P90X2, P90X3 |
141| notes | TEXT | Notes |
142
143**user_settings** (key/value store)
144
145| Key | Default | Description |
146|-----|---------|-------------|
147| weight_kg | 120 | Current weight |
148
149## Workout Rules
150
151- **Training days:** Monday, Wednesday, Friday
152- **Rest days:** Tuesday, Thursday, Saturday, Sunday
153- "done" on training day or next day = counted as trained
154- **Sarcasm trigger:** 2+ missed training days in last 14 days
155
156## Date Parsing
157
158Recognizes German phrases:
159- `heute` → today
160- `gestern` → yesterday
161- `vorgestern` → day before yesterday
162- `DD.MM.YYYY` → explicit date
163
164## Migration
165
166`--init` safely migrates existing v1 databases to v2 without data loss:
167- Adds new columns (`type`, `duration_min`, `calories`, `speed_kmh`, `weight_kg`)
168- Creates `workout_status`, `workout_rules`, and `user_settings` tables
169- Preserves all existing activity data