From 4e716d6800467e7d68f4604a2a0c60ad56f24144 Mon Sep 17 00:00:00 2001 From: Ron Klinkien Date: Sat, 12 Sep 2026 12:39:25 +0000 Subject: [PATCH] fix: read sleep respiration average from the correct API field daily_sleep.avg_respiration_value was aliased to 'avgRespirationValue', which never matches anything in a real Garmin response. Confirmed live against cyberjunky/home-assistant-garmin_connect's ha-garmin client (same bug, same root cause, fixed there in ha-garmin#28): Garmin's sleep-service dailySleepData nests the sleep-window average under 'averageRespirationValue'. lowestRespirationValue/highestRespirationValue were already correct - only the average field name was wrong. --- garminconnect/typed.py | 2 +- tests/test_typed.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/garminconnect/typed.py b/garminconnect/typed.py index 2094d536..29c1bdd6 100644 --- a/garminconnect/typed.py +++ b/garminconnect/typed.py @@ -214,7 +214,7 @@ class DailySleepDTO(_BaseResponse): avg_sleep_hrv: float | None = Field(default=None, alias="avgSleepHRV") avg_spo2: float | None = Field(default=None, alias="avgSpO2") avg_respiration_value: float | None = Field( - default=None, alias="avgRespirationValue" + default=None, alias="averageRespirationValue" ) lowest_respiration_value: float | None = Field( default=None, alias="lowestRespirationValue" diff --git a/tests/test_typed.py b/tests/test_typed.py index ab17c4d2..7e11a0fa 100644 --- a/tests/test_typed.py +++ b/tests/test_typed.py @@ -91,7 +91,7 @@ def garmin() -> garminconnect.Garmin: "sleepEndTimestampGMT": 1761125400000, "avgSleepHRV": 52.3, "avgSpO2": 96.0, - "avgRespirationValue": 14.2, + "averageRespirationValue": 14.2, "sleepScores": { "overall": {"value": 84, "qualifierKey": "GOOD"}, "totalDuration": {"value": 90, "qualifierKey": "EXCELLENT"}, @@ -242,6 +242,7 @@ def test_get_sleep_data_returns_nested_dto(garmin: garminconnect.Garmin) -> None assert sleep.daily_sleep_dto.sleep_time_seconds == 25200 assert sleep.daily_sleep_dto.deep_sleep_seconds == 5400 assert sleep.daily_sleep_dto.avg_sleep_hrv == 52.3 + assert sleep.daily_sleep_dto.avg_respiration_value == 14.2 # Nested scores are also typed assert sleep.daily_sleep_dto.sleep_scores is not None assert sleep.daily_sleep_dto.sleep_scores.overall is not None