Coder Social home page Coder Social logo

health's Introduction

health

Retrieve, store and plot your Fitbit data.

Usage

Register a new Fitbit app

Register a new app here and provide your oauth credentials in the file conf.cfg.
In order to get intra-days values for the heart rate, you should create a Personal app.
The callback URL should be http://127.0.0.1:8080/.

To get your access_token and refresh_token:

$ python gather_keys_oauth2.py client_id client_secret

Database configuration

Example with SQLite

Configure the connection in the file conf.cfg:

$ grep 'database_url' conf/conf.cfg
database_url = sqlite:///health.db

Then create and initialize the database:

$ ./fitbit-ctl.py db_initialize
reinitialize the database (yes/no) ? (default: no)  : yes

Example with PostgreSQL

Create a new PostgreSQL database (or MySQL) for this application and configure the connection in the file conf.cfg:

$ grep 'database_url' conf/conf.cfg
database_url = postgres://pgsqluser:[email protected]:5432/health

As you can see the line specifies:

  • the kind of the database (here postgres);
  • the database user name and password;
  • the database address and port;
  • the database name.

Then create and initialize the database:

$ ./create_db.sh
ALTER ROLE
GRANT
$ ./fitbit-ctl.py db_initialize
reinitialize the database (yes/no) ? (default: no)  : yes

Retrieve the data

Heart

$ ./fitbit-ctl.py retrieve_heart 5
Retrieving the heart rate for September 14, 2016...
Retrieving the heart rate for September 13, 2016...
Retrieving the heart rate for September 12, 2016...
Retrieving the heart rate for September 11, 2016...
Retrieving the heart rate for September 10, 2016...

$ ./fitbit-ctl.py plot_heart 2016-09-12
Generation of the graph...
$ gwenview 2016-09-12_heart.png

Weight

$ ./fitbit-ctl.py retrieve_weight 2016-09-01 2016-09-31
Retrieving the weight...

$ ./fitbit-ctl.py plot_weight
Generation of the graph...
$ gwenview weight.png

Help command

$ ./fitbit-ctl.py -h
usage: fitbit-ctl.py <command> [<args>]

positional arguments:
  command     the command to run

optional arguments:
  -h, --help  show this help message and exit

available commands:
  db_initialize            Initialize the database from conf parameters.
  plot_heart               Plot the data about the heart.
  plot_weight              Plot the data about the weight.
  retrieve_heart           Retrieve the data about the heart.
  retrieve_weight          Retrieve the data about the weight.

TODO

  • retrieve more data (sleep, activities, etc.).

Contact

Cédric Bonhomme

health's People

Contributors

cedricbonhomme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.