GarminDB icon indicating copy to clipboard operation
GarminDB copied to clipboard

No sleep data in database

Open sunshineRunner22 opened this issue 3 years ago • 10 comments

I've copied the following folders from my watch to C:\GARMIN Activity, Monitor, Settings, Sleep

I run the following command: C:\Anaconda3\Scripts>python garmindb_cli.py --sleep --copy --import --analyze

44 sleep fit-files are copied from "C:\garmin\sleep" to C:\Users\Admin\HealthData\FitFiles\Monitoring\2022 But the "Processing sleep data"-part of the script seems to be skipped (there is no progress bar). After the tables are generated the sleep-table in the garmin.db is empty and also in the other databases/tables there is no sleep data. What am I doing wrong?

sunshineRunner22 avatar Feb 15 '22 23:02 sunshineRunner22

I haven't tested local copy from watch to DB since I got a Fenix 6 which connects with MTP protocol. It's possible it isn't working anymore. What does the log file say? Test just the import: garmindb_cli.py --sleep --import and if that appears to be working, test just the analyze: garmindb_cli.py --sleep --analyze

tcgoetz avatar Mar 05 '22 13:03 tcgoetz

Actually, I think I see the issue. It's currently only matching JSON sleep files during import. What are the FIT sleep files named? Can you give me some examples?

tcgoetz avatar Mar 05 '22 13:03 tcgoetz

Depending on what the sleep FIt files are named, this might be a work around: C:\Anaconda3\Scripts>python garmindb_cli.py --sleep --copy followed by: C:\Anaconda3\Scripts>python garmindb_cli.py --monitoring --import --analyze Since I think the sleep FIT files have the same naming pattern as monitoring files and are in the monitoring directory.

tcgoetz avatar Mar 05 '22 14:03 tcgoetz

Example names of the FIT sleep file are: S1U00000.FIT, S2A00000.FIT, S2E00000.FIT, C1T83425.fit, S2E13300.FIT, etc. I tried C:\Anaconda3\Scripts>python garmindb_cli.py --monitoring --import --analyze and the 44 files were processed (but very fast, as if there wasn't happening anything in the background) and afterwards the tables were generated. But the sleep-table in the garmin.db is still empty also in the other databases/tables there is no sleep data. Is it even possible to extract the sleep data directly from the FIT-files (without using Garmin Connect)?

sunshineRunner22 avatar Mar 06 '22 19:03 sunshineRunner22

Sleep FIT files have the raw sleep levels at a point in time. It's a stream of sleep level and timestamp. From that you can construct the data in the sleep_events table, but the aggregate data in the sleep table will require summarizing the data in the sleep_events table.

tcgoetz avatar Mar 06 '22 19:03 tcgoetz

Please test the develop branch. see the above new commit. Update and set the new config item "sleep_from_fit" to true then import sleep data and it will import from FIT files rather than Garmin Connect downloads.

tcgoetz avatar Mar 07 '22 01:03 tcgoetz

Latest on develop has a better way to decide between getting sleep data from Garmin Connect and getting sleep data from FIT files. No config needed.

tcgoetz avatar Mar 07 '22 17:03 tcgoetz

After testing this, you should see that your sleep_events table has data. There is additional work needed to generate the data in the sleep table.

tcgoetz avatar Mar 07 '22 17:03 tcgoetz

Works great, the sleep_events table has data now! Thank you! Are you planning to generate the data for the sleep table as well in the future?

sunshineRunner22 avatar Mar 07 '22 22:03 sunshineRunner22

I will aggregate the stats in sleep_events to get per day totals of time in each sleep state at some point. Im not sure where the other data: sleep spo2, sleep rr, and sleep stress comes from right now.

tcgoetz avatar Mar 07 '22 23:03 tcgoetz