Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

An API to initiate the sleep calculation, while I am sleeping.

I am trying to write a companion app that wakes me up after 7 hours of sleep (sleep implies any of REM, light and deep stages). At a high level, here are the APIs that I will need:

1. an API to schedule a periodic job (preferably on the companion app)

  - This is needed to periodically count the hours slept. (Should be natively available)

2. an API to initiate the sleep calculation, while I am sleeping.

  - This is needed to know if hours slept has reached 7. (??)

3. an API to push down a "vibrate" signal to the fitbit device.

  - This is to awake me, once the hours slept has reached 7. (Haptics API seems promising)

 

I looked through the API reference, but I could not find anything concrete for #2. Is it possible?

Best Answer
0 Votes
3 REPLIES 3

Hi @nishantsny 

 

The sleep stage data is not available until the user wakes up and syncs their device with the mobile app.   This data is not calculated in real time.   If you need to determine when you're sleeping in real-time, then you'll need to use the heart rate and accelerometer data to determine that on your own.   

Some of your other questions are related to the Device SDK, so I'm moving your question to that forum group.  

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer

The Device API does now contain a basic sleep classifier, so you wouldn't need to use the companion.

 

https://dev.fitbit.com/blog/2020-09-10-announcing-fitbit-os-sdk-4.2/#sleep-api

Best Answer

@JonFitbit  Thanks, this looks promising. With this API, my workflow would be:

1. Poll this API every minute. Depending on the return value of the API, count the last minute towards the hours slept.

2. Once, hours slept reaches 7, push down vibrate signal to the device. 

 

Should I do #1 on device or on companion app?

I am worried that polling every minute may impact the device battery significantly. Also, not sure if the device has enough memory to store the data structures needed for #1.

Best Answer
0 Votes