Skip to content

fix: read sleep respiration average from the correct API field - #427

Merged
cyberjunky merged 1 commit into
masterfrom
fix/avg-sleep-respiration-field-name
Sep 12, 2026
Merged

cyberjunky merged 1 commit into
masterfrom
fix/avg-sleep-respiration-field-name

Conversation

@cyberjunky

@cyberjunky cyberjunky commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

DailySleepDTO.avg_respiration_value is aliased to "avgRespirationValue", which never matches a real Garmin response — the sleep-service dailySleepData endpoint nests the sleep-window average under averageRespirationValue. lowestRespirationValue/highestRespirationValue were already correct; only the average was wrong.

Found and confirmed live via a debug-log capture in cyberjunky/home-assistant-garmin_connect's ha-garmin client, which had the exact same bug (same field, same wrong name) — fixed there in cyberjunky/ha-garmin#28. Real response had 'averageRespirationValue': 15.0 alongside working deepSleepSeconds, sleepScores, etc., proving the endpoint itself is fine and only this one field alias was wrong.

Fix

Alias corrected to averageRespirationValue. Test fixture/assertion updated to match the real field name.

Summary by CodeRabbit

  • Bug Fixes

    • Corrected sleep data parsing for average respiration values, ensuring the reported value is displayed accurately.
  • Tests

    • Updated sleep data validation to reflect the corrected respiration 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.
@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 6cf53d97-0e45-441e-bd9b-bb16cb80f172

📥 Commits

Reviewing files that changed from the base of the PR and between 6569a42 and 4e716d6.

📒 Files selected for processing (2)
  • garminconnect/typed.py
  • tests/test_typed.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

The sleep DTO now maps averageRespirationValue to avg_respiration_value. The nested DTO test fixture and assertion use the renamed field.

Changes

Sleep respiration alias

Layer / File(s) Summary
Update sleep respiration mapping
garminconnect/typed.py, tests/test_typed.py
DailySleepDTO.avg_respiration_value now uses the averageRespirationValue alias. The fixture and test assertion validate the updated mapping.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 4e716

The focused alias correction is covered by its updated test and presents no actionable merge risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: reading the sleep respiration average from the corrected API field.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/avg-sleep-respiration-field-name

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cyberjunky
cyberjunky merged commit 084f768 into master Sep 12, 2026
8 checks passed
@cyberjunky
cyberjunky deleted the fix/avg-sleep-respiration-field-name branch September 12, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant