cyberjunky / python-garminconnect

Python 3 API wrapper for Garmin Connect to get activity statistics
MIT License
802 stars 132 forks source link

Adding endpoint for getting primary training device information #194

Closed psdupvi closed 3 months ago

psdupvi commented 3 months ago

Returns primary training device info, as well as a list of all devices. We could adjust it slightly if we wanted to minimize the return data to just Primary Training Device info, but I'm not sure if that's necessary.

That would look like...

...
response = self.connectapi(url)
del response['RegisteredDevices']
return response 

Return data looks like:

{'PrimaryTrainingDevice': {'deviceId': XXX},
 'WearableDevices': {'deviceWeights': [{'displayName': 'Forerunner 955 Solar',
    'deviceId': XXX,
    'imageUrl': 'https://s3.amazonaws.com/garmin-connect-prod/profile_images/98d07f81-3a9f-4d5a-9172-45c6c3080d36-71.png',
    'weight': 3,
    'primaryTrainingCapable': True,
    'lhaBackupCapable': True,
    'primaryWearableDevice': True},
   {'displayName': 'Forerunner 945',
    'deviceId': XXX,
    'imageUrl': 'https://static.garmincdn.com/com.garmin.connect/content/images/device-images/forerunner-945.png',
    'weight': 1,
    'primaryTrainingCapable': False,
    'lhaBackupCapable': False,
    'trainingStatusCapable': True}],
  'wearableDeviceCount': 2},
 'TrainingStatusOnlyDevices': {'deviceWeights': [{'displayName': 'Forerunner 945',
    'deviceId': XXX,
    'imageUrl': 'https://static.garmincdn.com/com.garmin.connect/content/images/device-images/forerunner-945.png',
    'weight': 1,
    'primaryTrainingCapable': False,
    'lhaBackupCapable': False,
    'trainingStatusCapable': True}]},
 'PrimaryTrainingDevices': {'deviceWeights': [{'displayName': 'Forerunner 955 Solar',
    'deviceId': XXX,
    'imageUrl': 'https://s3.amazonaws.com/garmin-connect-prod/profile_images/98d07f81-3a9f-4d5a-9172-45c6c3080d36-71.png',
    'weight': 3,
    'primaryTrainingCapable': True,
    'lhaBackupCapable': True,
    'primaryWearableDevice': True}],
  'primaryTrainingDeviceCount': 1},
'RegisteredDevices': [
   ...list of devices as in get_devices() return
]
}
cyberjunky commented 3 months ago

Thanks (again), I removed the _info part from the method to be more consistent (I don't know with what haha... this pkg is growing faster then my head/time can manage LOL) but great addition once more!

psdupvi commented 3 months ago

Thanks!

That's the joy of open source -- we can always add things and if it takes you time to approve, who cares. Thanks for putting all this together