From 2e99a5bbfa69a4fbafd152a35df502308fe2b4d9 Mon Sep 17 00:00:00 2001 From: Ron Klinkien Date: Sat, 6 Jul 2024 11:49:30 +0200 Subject: [PATCH] Add access to Fitness Age data by @fako1024 Add grouping option to progress summary and fix type annotations by @tboerstad --- README.md | 73 ++++++++++++++++++++------------------- garminconnect/__init__.py | 16 ++++----- pyproject.toml | 2 +- 3 files changed, 46 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index d693562..67569f9 100644 --- a/README.md +++ b/README.md @@ -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' @@ -34,7 +34,7 @@ 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 @@ -42,30 +42,31 @@ 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/) diff --git a/garminconnect/__init__.py b/garminconnect/__init__.py index ba824e2..acb25c7 100644 --- a/garminconnect/__init__.py +++ b/garminconnect/__init__.py @@ -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'.""" @@ -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' diff --git a/pyproject.toml b/pyproject.toml index d0ee85b..807def7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = "ron@cyberjunky.nl"},