Skip to content

Commit

Permalink
Issue #150: better way to handle sleep data from garmin connect vs sl…
Browse files Browse the repository at this point in the history
…eep data from FIT files. Needs no config
  • Loading branch information
Tom Goetz committed Mar 7, 2022
1 parent c1921f3 commit fc02bee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
3 changes: 1 addition & 2 deletions garmindb/GarminConnectConfig.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"rhr_start_date" : "01/01/2019",
"monitoring_start_date" : "01/01/2019",
"download_latest_activities" : 25,
"download_all_activities" : 1000,
"sleep_from_fit" : false
"download_all_activities" : 1000
},
"copy": {
"mount_dir" : "/Volumes/GARMIN"
Expand Down
4 changes: 0 additions & 4 deletions garmindb/garmin_connect_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ def stat_start_date(self, stat_type):
days = (datetime.datetime.now().date() - date).days
return (date, days)

def sleep_from_fit(self):
"""Return a boolean. True means sleep data comes from FIT files. False means sleep data comes from Garmin Connect downloads."""
return self.__get_node_value('data', 'sleep_from_fit')

def device_mount_dir(self):
"""Return the directory where the Garmin USB device is mounted."""
return self.__get_node_value('copy', 'mount_dir')
Expand Down
12 changes: 6 additions & 6 deletions scripts/garmindb_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ def import_data(debug, latest, stats):
gfd.process_files(MonitoringFitFileProcessor(db_params_dict, plugin_manager, debug))

if Statistics.sleep in stats:
if gc_config.sleep_from_fit():
# If we have sleep data from Garmin connect, use it, otherwise process FIT sleep files.
sleep_dir = ConfigManager.get_or_create_sleep_dir()
gsd = GarminSleepData(db_params_dict, sleep_dir, latest, debug)
if gsd.file_count() > 0:
gsd.process()
else:
gsd = GarminSleepFitData(monitoring_dir, latest=False, measurement_system=measurement_system, debug=2)
if gsd.file_count() > 0:
gsd.process_files(SleepFitFileProcessor(db_params_dict))
else:
sleep_dir = ConfigManager.get_or_create_sleep_dir()
gsd = GarminSleepData(db_params_dict, sleep_dir, latest, debug)
if gsd.file_count() > 0:
gsd.process()

if Statistics.rhr in stats:
rhr_dir = ConfigManager.get_or_create_rhr_dir()
Expand Down

0 comments on commit fc02bee

Please sign in to comment.