Skip to content

Add multi-device support for training status endpoints #131

@matin

Description

@matin

Description

The current training status implementation only supports single-device scenarios. The code assumes the first device in the API response and ignores additional devices.

Current Limitation

In the _parse_response methods for training status classes, we use:

# Get the first device's data (assumes single device for now)
for device_data in report_data.values():
    # Process only the first device and return
    return [device_data] if isinstance(device_data, dict) else result

Proposed Enhancement

Add support for multiple devices by:

  1. Processing all devices in the API response instead of just the first one
  2. Adding device identification to the returned data structures
  3. Updating the data model to include device-specific information
  4. Maintaining backward compatibility with existing single-device usage

Implementation Ideas

  • Add a device_id field to clearly identify which device each training status entry belongs to
  • Modify _parse_response to iterate through all devices in reportData
  • Consider adding a class method like list_by_device() for device-specific queries
  • Update tests to cover multi-device scenarios

Files Affected

  • src/garth/stats/training_status/daily.py
  • src/garth/stats/training_status/weekly.py
  • src/garth/stats/training_status/monthly.py
  • tests/stats/test_training_status.py

Priority

Low - Current single-device support covers most use cases, but this would be valuable for users with multiple Garmin devices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions