2
2
3
3
import logging
4
4
import os
5
- from datetime import datetime , timezone , date
5
+ from datetime import date , datetime , timezone
6
6
from enum import Enum , auto
7
7
from typing import Any , Dict , List , Optional
8
8
@@ -47,7 +47,7 @@ def __init__(
47
47
self .garmin_connect_daily_hydration_url = (
48
48
"/usersummary-service/usersummary/hydration/daily"
49
49
)
50
- self .garmin_connect_set_hydration_url = (
50
+ self .garmin_connect_set_hydration_url = (
51
51
"usersummary-service/usersummary/hydration/log"
52
52
)
53
53
self .garmin_connect_daily_stats_steps_url = (
@@ -495,7 +495,9 @@ def get_max_metrics(self, cdate: str) -> Dict[str, Any]:
495
495
496
496
return self .connectapi (url )
497
497
498
- def add_hydration_data (self , value_in_ml : float , timestamp = None , cdate : str = None ) -> Dict [str , Any ]:
498
+ def add_hydration_data (
499
+ self , value_in_ml : float , timestamp = None , cdate : Optional [str ] = None
500
+ ) -> Dict [str , Any ]:
499
501
"""Add hydration data in ml. Defaults to current date and current timestamp if left empty
500
502
:param float required - value_in_ml: The number of ml of water you wish to add (positive) or subtract (negative)
501
503
:param timestamp optional - timestamp: The timestamp of the hydration update, format 'YYYY-MM-DDThh:mm:ss.ms' Defaults to current timestamp
@@ -784,7 +786,7 @@ def get_hill_score(self, startdate: str, enddate=None):
784
786
785
787
return self .connectapi (url , params = params )
786
788
787
- def get_devices (self ) -> Dict [str , Any ]:
789
+ def get_devices (self ) -> List [ Dict [str , Any ] ]:
788
790
"""Return available devices for the current user account."""
789
791
790
792
url = self .garmin_connect_devices_url
@@ -826,7 +828,7 @@ def get_device_solar_data(
826
828
827
829
return self .connectapi (url , params = params )["deviceSolarInput" ]
828
830
829
- def get_device_alarms (self ) -> Dict [ str , Any ]:
831
+ def get_device_alarms (self ) -> List [ Any ]:
830
832
"""Get list of active alarms from all devices."""
831
833
832
834
logger .debug ("Requesting device alarms" )
@@ -959,14 +961,15 @@ def get_activities_by_date(self, startdate, enddate, activitytype=None):
959
961
return activities
960
962
961
963
def get_progress_summary_between_dates (
962
- self , startdate , enddate , metric = "distance"
964
+ self , startdate , enddate , metric = "distance" , groupbyactivities = True
963
965
):
964
966
"""
965
967
Fetch progress summary data between specific dates
966
968
:param startdate: String in the format YYYY-MM-DD
967
969
:param enddate: String in the format YYYY-MM-DD
968
970
:param metric: metric to be calculated in the summary:
969
971
"elevationGain", "duration", "distance", "movingDuration"
972
+ :param groupbyactivities: group the summary by activity type
970
973
:return: list of JSON activities with their aggregated progress summary
971
974
"""
972
975
@@ -975,7 +978,7 @@ def get_progress_summary_between_dates(
975
978
"startDate" : str (startdate ),
976
979
"endDate" : str (enddate ),
977
980
"aggregation" : "lifetime" ,
978
- "groupByParentActivityType" : "true" ,
981
+ "groupByParentActivityType" : str ( groupbyactivities ) ,
979
982
"metric" : str (metric ),
980
983
}
981
984
0 commit comments