Skip to content

Commit

Permalink
Add access to Fitness Age data by @fako1024
Browse files Browse the repository at this point in the history
Add grouping option to progress summary and fix type annotations by @tboerstad
  • Loading branch information
cyberjunky committed Jul 6, 2024
1 parent a2ebecb commit 2e99a5b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 45 deletions.
73 changes: 37 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ $ ./example.py
1 -- Get full name
2 -- Get unit system
3 -- Get activity data for '2024-03-15'
4 -- Get activity data for '2024-03-15' (compatible with garminconnect-ha)
5 -- Get body composition data for '2024-03-15' (compatible with garminconnect-ha)
6 -- Get body composition data for from '2024-03-08' to '2024-03-15' (to be compatible with garminconnect-ha)
7 -- Get stats and body composition data for '2024-03-15'
8 -- Get steps data for '2024-03-15'
9 -- Get heart rate data for '2024-03-15'
0 -- Get training readiness data for '2024-03-15'
- -- Get daily step data for '2024-03-08' to '2024-03-15'
/ -- Get body battery data for '2024-03-08' to '2024-03-15'
! -- Get floors data for '2024-03-08'
? -- Get blood pressure data for '2024-03-08' to '2024-03-15'
. -- Get training status data for '2024-03-15'
a -- Get resting heart rate data for 2024-03-15'
b -- Get hydration data for '2024-03-15'
c -- Get sleep data for '2024-03-15'
d -- Get stress data for '2024-03-15'
e -- Get respiration data for '2024-03-15'
f -- Get SpO2 data for '2024-03-15'
g -- Get max metric data (like vo2MaxValue and fitnessAge) for '2024-03-15'
3 -- Get activity data for '2024-07-06'
4 -- Get activity data for '2024-07-06' (compatible with garminconnect-ha)
5 -- Get body composition data for '2024-07-06' (compatible with garminconnect-ha)
6 -- Get body composition data for from '2024-06-29' to '2024-07-06' (to be compatible with garminconnect-ha)
7 -- Get stats and body composition data for '2024-07-06'
8 -- Get steps data for '2024-07-06'
9 -- Get heart rate data for '2024-07-06'
0 -- Get training readiness data for '2024-07-06'
- -- Get daily step data for '2024-06-29' to '2024-07-06'
/ -- Get body battery data for '2024-06-29' to '2024-07-06'
! -- Get floors data for '2024-06-29'
? -- Get blood pressure data for '2024-06-29' to '2024-07-06'
. -- Get training status data for '2024-07-06'
a -- Get resting heart rate data for 2024-07-06'
b -- Get hydration data for '2024-07-06'
c -- Get sleep data for '2024-07-06'
d -- Get stress data for '2024-07-06'
e -- Get respiration data for '2024-07-06'
f -- Get SpO2 data for '2024-07-06'
g -- Get max metric data (like vo2MaxValue and fitnessAge) for '2024-07-06'
h -- Get personal record for user
i -- Get earned badges for user
j -- Get adhoc challenges data from start '0' and limit '100'
Expand All @@ -34,38 +34,39 @@ l -- Get badge challenges data from '1' and limit '100'
m -- Get non completed badge challenges data from '1' and limit '100'
n -- Get activities data from start '0' and limit '100'
o -- Get last activity
p -- Download activities data by date from '2024-03-08' to '2024-03-15'
p -- Download activities data by date from '2024-06-29' to '2024-07-06'
r -- Get all kinds of activities data from '0'
s -- Upload activity data from file 'MY_ACTIVITY.fit'
t -- Get all kinds of Garmin device info
u -- Get active goals
v -- Get future goals
w -- Get past goals
y -- Get all Garmin device alarms
x -- Get Heart Rate Variability data (HRV) for '2024-03-15'
z -- Get progress summary from '2024-03-08' to '2024-03-15' for all metrics
x -- Get Heart Rate Variability data (HRV) for '2024-07-06'
z -- Get progress summary from '2024-06-29' to '2024-07-06' for all metrics
A -- Get gear, the defaults, activity types and statistics
B -- Get weight-ins from '2024-03-08' to '2024-03-15'
C -- Get daily weigh-ins for '2024-03-15'
D -- Delete all weigh-ins for '2024-03-15'
E -- Add a weigh-in of 89.6kg on '2024-03-15'
F -- Get virtual challenges/expeditions from '2024-03-08' to '2024-03-15'
G -- Get hill score data from '2024-03-08' to '2024-03-15'
H -- Get endurance score data from '2024-03-08' to '2024-03-15'
I -- Get activities for date '2024-03-15'
B -- Get weight-ins from '2024-06-29' to '2024-07-06'
C -- Get daily weigh-ins for '2024-07-06'
D -- Delete all weigh-ins for '2024-07-06'
E -- Add a weigh-in of 89.6kg on '2024-07-06'
F -- Get virtual challenges/expeditions from '2024-06-29' to '2024-07-06'
G -- Get hill score data from '2024-06-29' to '2024-07-06'
H -- Get endurance score data from '2024-06-29' to '2024-07-06'
I -- Get activities for date '2024-07-06'
J -- Get race predictions
K -- Get all day stress data for '2024-03-15'
L -- Add body composition for '2024-03-15'
K -- Get all day stress data for '2024-07-06'
L -- Add body composition for '2024-07-06'
M -- Set blood pressure '120,80,80,notes='Testing with example.py'
N -- Get user profile/settings
O -- Reload epoch data for 2024-03-15
O -- Reload epoch data for 2024-07-06
P -- Get workouts 0-100, get and download last one to .FIT file
R -- Get solar data from your devices
S -- Get pregnancy summary data
T -- Add hydration data (1 cup) for today
T -- Add hydration data
U -- Get Fitness Age data for 2024-07-06
Z -- Remove stored login tokens (logout)
q -- Exit
Make your selection:
Make your selection:
```

[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/cyberjunkynl/)
Expand Down
16 changes: 8 additions & 8 deletions garminconnect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,27 +512,27 @@ def add_hydration_data(
cdate = str(raw_date)

raw_ts = datetime.now()
timestamp = datetime.strftime(raw_ts, '%Y-%m-%dT%H:%M:%S.%f')
timestamp = datetime.strftime(raw_ts, "%Y-%m-%dT%H:%M:%S.%f")

elif cdate is not None and timestamp is None:
# If cdate is not null, use timestamp associated with midnight
raw_ts = datetime.strptime(cdate, '%Y-%m-%d')
timestamp = datetime.strftime(raw_ts, '%Y-%m-%dT%H:%M:%S.%f')
raw_ts = datetime.strptime(cdate, "%Y-%m-%d")
timestamp = datetime.strftime(raw_ts, "%Y-%m-%dT%H:%M:%S.%f")

elif cdate is None and timestamp is not None:
# If timestamp is not null, set cdate equal to date part of timestamp
raw_ts = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%f')
raw_ts = datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%f")
cdate = str(raw_ts.date())

payload = {
"calendarDate": cdate,
"timestampLocal": timestamp,
"valueInML": value_in_ml
}
"valueInML": value_in_ml,
}

logger.debug("Adding hydration data")

return self.garth.put('connectapi', url, json=payload)
return self.garth.put("connectapi", url, json=payload)

def get_hydration_data(self, cdate: str) -> Dict[str, Any]:
"""Return available hydration data 'cdate' format 'YYYY-MM-DD'."""
Expand Down Expand Up @@ -761,7 +761,7 @@ def get_fitnessage_data(self, cdate: str) -> Dict[str, Any]:
logger.debug("Requesting Fitness Age data")

return self.connectapi(url)

def get_hill_score(self, startdate: str, enddate=None):
"""
Return hill score by day from 'startdate' format 'YYYY-MM-DD'
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "garminconnect"
version = "0.2.18"
version = "0.2.19"
description = "Python 3 API wrapper for Garmin Connect"
authors = [
{name = "Ron Klinkien", email = "[email protected]"},
Expand Down

0 comments on commit 2e99a5b

Please sign in to comment.