04-17-2021 23:16
04-17-2021 23:16
I am trying to add the new Fitbit sleep API to my app and I followed the exact instructions on the Fitbit API site (https://dev.fitbit.com/build/reference/device-api/sleep/).
I put this in my app:
import sleep from "sleep"
if (sleep) {
sleep.onchange = () => {
console.log(`User sleep state is: ${sleep!.state}`)
}
} else {
console.log("Sleep API not supported on this device, or no permission")
}
This does not work. The backtick in console.log is poorly placed and does not even build and when I remove the exclamation mark it keeps posting asleep when I am awake and wearing the watch. What is the problem?
Answered! Go to the Best Answer.
Best Answer04-30-2021 06:15
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
04-30-2021 06:15
You're right, that rogue exclamation mark is a TypeScript'ism, sorry.
The detection is a basic sleep classifier, but if you're moving it shouldn't think you're asleep. Are you sitting completely still when it reports you're asleep?
Best Answer04-30-2021 06:15
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
04-30-2021 06:15
You're right, that rogue exclamation mark is a TypeScript'ism, sorry.
The detection is a basic sleep classifier, but if you're moving it shouldn't think you're asleep. Are you sitting completely still when it reports you're asleep?
Best Answer05-06-2021 17:48
05-06-2021 17:48
It is just not super accurate. It is useful though as a point of reference among other variables. Thanks for your response Jon.
Best Answer