Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade sleep to use Fitbit v1.2 API #78

Merged
merged 1 commit into from
Mar 21, 2021
Merged

Conversation

dwoffinden
Copy link
Contributor

  • Fix pre-midnight sleeps being shifted forwards a day, in the new API
    the point includes the full date and time, avoiding the confusion.
  • Fix stages being uncategoried, the old code checked for 1/2/3 as ints
    when they were actually strings, the new API includes more types, and
    uses strings.
  • I think the new API is also more granular (down to 30s) but less dense
    (it returns one point per stage, and tells you how long it lasted).

Old: https://dev.fitbit.com/build/reference/web-api/sleep-v1
New: https://dev.fitbit.com/build/reference/web-api/sleep

Workaround to enable it:
orcasgit/python-fitbit#128

TODO: switch to the new GFit sleep segment API:
https://developers.google.com/android/reference/com/google/android/gms/fitness/data/SleepStages

- Fix pre-midnight sleeps being shifted forwards a day, in the new API
  the point includes the full date and time, avoiding the confusion.
- Fix stages being uncategoried, the old code checked for 1/2/3 as ints
  when they were actually strings, the new API includes more types, and
  uses strings.
- I think the new API is also more granular (down to 30s) but less dense
  (it returns one point per stage, and tells you how long it lasted).

Old: https://dev.fitbit.com/build/reference/web-api/sleep-v1
New: https://dev.fitbit.com/build/reference/web-api/sleep

Workaround to enable it:
orcasgit/python-fitbit#128

TODO: switch to the new GFit sleep segment API:
https://developers.google.com/android/reference/com/google/android/gms/fitness/data/SleepStages
Copy link
Owner

@pkpio pkpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you 👍

@pkpio
Copy link
Owner

pkpio commented Mar 21, 2021

Feel free to open an issue for the TODO. I will go ahead and merge these changes.

@pkpio pkpio merged commit c6e6190 into pkpio:master Mar 21, 2021
@dwoffinden dwoffinden deleted the sleep-1.2 branch March 21, 2021 13:15
@dwoffinden
Copy link
Contributor Author

Thanks! I'll try to dig into some official documentation on the newer API, for now this seems to work well :)

@nattofriends
Copy link

nattofriends commented Mar 24, 2021

I implemented the sleep segment API support on top of Woyken's fork recently, it wasn't too hard (although I would much prefer to use this repo as is). The REST side documentation for the sleep segment changes are at https://developers.google.com/fit/improvements and https://developers.google.com/fit/datatypes/sleep.

@pkpio
Copy link
Owner

pkpio commented Mar 24, 2021

I implemented the sleep segment API support on top of Woyken's fork recently, it wasn't too hard (although I would much prefer to use this repo as is). The REST side documentation for the sleep segment changes are at https://developers.google.com/fit/improvements and https://developers.google.com/fit/datatypes/sleep.

Happy to review and work to get your changes merged if you could open a PR? Thank you 😁

@dwoffinden dwoffinden mentioned this pull request Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants