tcgoetz / GarminDB

Download and parse data from Garmin Connect or a Garmin watch, FitBit CSV, and MS Health CSV files into and analyze data in Sqlite serverless databases with Jupyter notebooks.
GNU General Public License v2.0
1.11k stars 137 forks source link

No sleep data in database #150

Open sunshineRunner22 opened 2 years ago

sunshineRunner22 commented 2 years ago

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?

tcgoetz commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.

sunshineRunner22 commented 2 years ago

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)?

tcgoetz commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.

sunshineRunner22 commented 2 years ago

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?

tcgoetz commented 2 years ago

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.