diff --git a/Makefile b/Makefile index 1030782..4d001b2 100644 --- a/Makefile +++ b/Makefile @@ -26,12 +26,12 @@ rebuild-lockfiles: .pdm format: .pdm pdm run isort $(sources) pdm run black -l 79 $(sources) - pdm run ruff --fix $(sources) + pdm run ruff check $(sources) .PHONY: lint ## Lint python source files lint: .pdm pdm run isort --check-only $(sources) - pdm run ruff $(sources) + pdm run ruff check $(sources) pdm run black -l 79 $(sources) --check --diff pdm run mypy $(sources) diff --git a/README.md b/README.md index af4826a..4233179 100644 --- a/README.md +++ b/README.md @@ -2,31 +2,30 @@ ``` $ ./example.py - *** Garmin Connect API Demo by cyberjunky *** 1 -- Get full name 2 -- Get unit system -3 -- Get activity data for '2024-01-21' -4 -- Get activity data for '2024-01-21' (compatible with garminconnect-ha) -5 -- Get body composition data for '2024-01-21' (compatible with garminconnect-ha) -6 -- Get body composition data for from '2024-01-14' to '2024-01-21' (to be compatible with garminconnect-ha) -7 -- Get stats and body composition data for '2024-01-21' -8 -- Get steps data for '2024-01-21' -9 -- Get heart rate data for '2024-01-21' -0 -- Get training readiness data for '2024-01-21' -- -- Get daily step data for '2024-01-14' to '2024-01-21' -/ -- Get body battery data for '2024-01-14' to '2024-01-21' -! -- Get floors data for '2024-01-14' -? -- Get blood pressure data for '2024-01-14' to '2024-01-21' -. -- Get training status data for '2024-01-21' -a -- Get resting heart rate data for 2024-01-21' -b -- Get hydration data for '2024-01-21' -c -- Get sleep data for '2024-01-21' -d -- Get stress data for '2024-01-21' -e -- Get respiration data for '2024-01-21' -f -- Get SpO2 data for '2024-01-21' -g -- Get max metric data (like vo2MaxValue and fitnessAge) for '2024-01-21' +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' h -- Get personal record for user i -- Get earned badges for user j -- Get adhoc challenges data from start '0' and limit '100' @@ -35,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-01-14' to '2024-01-21' +p -- Download activities data by date from '2024-03-08' to '2024-03-15' 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 @@ -43,27 +42,29 @@ 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-01-21' -z -- Get progress summary from '2024-01-14' to '2024-01-21' for all metrics +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 A -- Get gear, the defaults, activity types and statistics -B -- Get weight-ins from '2024-01-14' to '2024-01-21' -C -- Get daily weigh-ins for '2024-01-21' -D -- Delete all weigh-ins for '2024-01-21' -E -- Add a weigh-in of 89.6kg on '2024-01-21' -F -- Get virtual challenges/expeditions from '2024-01-14' to '2024-01-21' -G -- Get hill score data from '2024-01-14' to '2024-01-21' -H -- Get endurance score data from '2024-01-14' to '2024-01-21' -I -- Get activities for date '2024-01-21' +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' J -- Get race predictions -K -- Get all day stress data for '2024-01-21' -L -- Add body composition for '2024-01-21' +K -- Get all day stress data for '2024-03-15' +L -- Add body composition for '2024-03-15' M -- Set blood pressure '120,80,80,notes='Testing with example.py' N -- Get user profile/settings -O -- Reload epoch data for 2024-01-21 -P -- Get workouts and get and download last one to .fit file +O -- Reload epoch data for 2024-03-15 +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 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/) @@ -105,11 +106,14 @@ make test To create a development environment to commit code. ``` +make .venv +source .venv/bin/activate + pip3 install pdm pip3 install ruff pdm init -sudo apt install pre-commit +sudo apt install pre-commit isort black mypy pip3 install pre-commit ``` Run checks before PR/Commit: @@ -119,6 +123,20 @@ make lint make codespell ``` +## Publish + +To publish new package (author only) + +``` +sudo apt install twine +vi ~/.pypirc +[pypi] +username = __token__ +password = + +make publish +``` + ## Example The tests provide examples of how to use the library. There is a Jupyter notebook called `reference.ipynb` provided [here](https://github.com/cyberjunky/python-garminconnect/blob/master/reference.ipynb). diff --git a/garminconnect/__init__.py b/garminconnect/__init__.py index fb46b05..ca493b8 100644 --- a/garminconnect/__init__.py +++ b/garminconnect/__init__.py @@ -167,9 +167,7 @@ def __init__(self, email=None, password=None, is_cn=False): self.garmin_workouts = "/workout-service" - self.garmin_connect_delete_activity_url = ( - "/activity-service/activity" - ) + self.garmin_connect_delete_activity_url = "/activity-service/activity" self.garth = garth.Client( domain="garmin.cn" if is_cn else "garmin.com" @@ -743,7 +741,9 @@ def get_device_settings(self, device_id: str) -> Dict[str, Any]: return self.connectapi(url) - def get_device_solar_data(self, device_id: str, startdate: str, enddate: str = None) -> Dict[str, Any]: + def get_device_solar_data( + self, device_id: str, startdate: str, enddate=None + ) -> Dict[str, Any]: """Return solar data for compatible device with 'device_id'""" if enddate is None: enddate = startdate @@ -751,11 +751,11 @@ def get_device_solar_data(self, device_id: str, startdate: str, enddate: str = N else: single_day = False - params = {'singleDayView': single_day} + params = {"singleDayView": single_day} url = f"{self.garmin_connect_solar_url}/{device_id}/{startdate}/{enddate}" - return self.connectapi(url, params=params)['deviceSolarInput'] + return self.connectapi(url, params=params)["deviceSolarInput"] def get_device_alarms(self) -> Dict[str, Any]: """Get list of active alarms from all devices.""" @@ -1170,7 +1170,9 @@ def get_menstrual_calendar_data(self, startdate: str, enddate: str): """Return summaries of cycles that have days between startdate and enddate.""" url = f"{self.garmin_connect_menstrual_calendar_url}/{startdate}/{enddate}" - logger.debug(f"Requesting menstrual data for dates {startdate} through {enddate}") + logger.debug( + f"Requesting menstrual data for dates {startdate} through {enddate}" + ) return self.connectapi(url) diff --git a/pyproject.toml b/pyproject.toml index a4a3eec..ef9888b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "garminconnect" -version = "0.2.13" +version = "0.2.14" description = "Python 3 API wrapper for Garmin Connect" authors = [ {name = "Ron Klinkien", email = "ron@cyberjunky.nl"}, @@ -43,8 +43,7 @@ line_length = 79 known_first_party = "garminconnect" [tool.pdm] -package-type = "library" - +distribution = true [tool.pdm.dev-dependencies] dev = [ "ipython", diff --git a/requirements-test.txt b/requirements-test.txt index 3714b2b..fde00eb 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,4 +1,4 @@ pytest pytest-vcr pytest-cov -coverage +coverage \ No newline at end of file