09-19-2023 06:44
09-19-2023 06:44
Hi,
I really want to check if I am sleeping or not by fitbit, because I want to stop playing the video and turn off the light in my room when I fall asleep.
I have Sense 2, so I can't use Device API, which can describe whether the user is asleep or not.
Therefore, I have no choice but to try to use the web API.
Firstly, I wrote a code that runs every hour and gets the latest sleep log of that day by Google Apps Script.
I thought that if I was asleep, the startTime would be detected but not the endTime, which would tell me if I was asleep or not.
Next, I tried sleeping from 3 AM to 11 AM.
Finally, I found that when I was sleeping, the sleep data didn't exist just like before I went to bed, and once I woke up at 11, the sleep log was found.
How can I check if I am sleeping or not?
09-19-2023 13:40
09-19-2023 13:40
Hi @Koyama
The sleep log data is not available until you sync your device AFTER you wake up. Sleep data is not available while you are sleep. Instead, you could monitor your heart rate and look for a decrease heart rate range where determines when you are sleep. Check your heart rate history to see what the values are when you are sleeping and use that as a guideline for when you might be sleeping in the future.
Gordon