Monday, May 21, 2012

Withings wifi scale python dashboard using matplotlib and pandas

The Withings wifi scale is a great bit of hardware, much more visually appealing than my handmade equivalent and wifi makes it standalone, also a big advantage over my bluetooth scale. I've been using the scale to log my weight and using fatsecret to track caloric intake for a while now and decided it would be nice to make a dashboard integrating data from both sources. The plots on Withings' website leave much to be desired. Thankfully, both Withings and fatsecret have APIs which make third party apps possible. Below I'll show some code that uses the rauth library to access both services. rauth provides OAuth 1.0/a, 2.0, and Ofly consumer support. You can install rauth using easy_install:
sudo easy_install rauth
Before using the Withings and fatsecret APIs, you'll need to register as a developer, you can do that by following the links below:
Withings developer registration:
https://oauth.withings.com/en/partner/add
If you just want to extend the code I provide further down you can fill an arbitrary value for the "Application Website" and "Organization" fields and leave the Callback URL blank. Otherwise, fill in those fields according to your needs. Once you've registered as a developer with both services you will have your Consumer Key and Shared Secret which you will need to send API requests. Now grab my python code from github:

git clone https://github.com/trtg/pywithings.git

The git repo has two files: withings.py(the actual library itself) and example.py (seen below). Open up example.py and fill in your consumer key, consumer secret, and the email address you used to register with Withings as indicated. Using the library is pretty straightforward: instantiate a withings object and then just call get_weights() to retrieve a list of weight measurements and an associated list of dates (in seconds since the epoch format) which you can then use however you'd like. Note that the very first time you run example.py you will be prompted to authorize the app to access your withings account by pasting a URL into your browser. Once you go to that URL and login, you will see a screen like this:
After you click "allow" you will see an oauth token string as shown below. Copy just the part after "oauth_verifier=" , in this case PZBDNyyuxDnGkeMxccY.
Paste the "PZ..." string into your terminal where prompted, hit enter, and you should get a graph like the one below.(Click on the graph to see a larger version) I used the python package pandas to treat the weight data as a time series and get nice date labels on the x-axis as well as to plot the smooth red rolling average of the data.
In an upcoming post, I'll discuss similar code that retrieves data from fatsecret to generate plots like the one below:

15 comments:

  1. Wi-Fi Alliance is pioneer in developing WiFi technology and all the hardware associated with Wifi is mostly certified by Wifi Alliance compliance.check out wolffofcanada.com

    ReplyDelete
  2. Coach Outlet Store Online is one of the best fashion bags in the world. Coach Outlet Online is known for its best quality bags that are usually used by actresses and also rich people. If you are a person who cares about fashion, I think that you should buy a Coach Factory Outlet Online. If you want to buy this awesome bag, you should find a Coach Outlet Online Store in our online store. Antonio Brown Color Rush Jersey can often be found here for pennies on the dollar. For sports fans out there nothing is better than watching a game and wearing your favorite Detroit Red Wings Standings. Many of the special throwback or Pittsburgh Penguins Standings cost way too much money for each one. Often times we have may players we love so getting all their Chicago Blackhawks Standings would cost way too much money. Many of the popular Cheap NBA Basketball Jerseys sell out quickly. Cheap NHL Jerseys could be truly expensive, most especially if they are authentic and come from real sports stars. Nonetheless if you are opting for affordable ones then there are Wholesale NFL Jerseys then there are actually then you can actually buy some that are good quality. Still you can purchase Cheap Authentic Nfl Jerseys which are in reasonable rates if you try to search for it. You can look around the house or ask permission to roam their closets and you may find one or two Cheap Nfl Nike Elite Jerseys. Well, this could be a nice way for you to get Salute To Service Jersey for free. Also you can purchase Nba Quiz Playbuzz located at salvation army shops which sells Chicago Bears Bleacher Report at dropout price. Maglie Calcio A Poco Prezzo,Maillot Pas Cher Foot,Camisetas De Futbol Comprar,Camisetas De Futbol Baratas

    ReplyDelete
  3. How Many Calories Does Movie Popcorn Have? A small movie theater popcorn with "butter" has about as many calories as: A milk chocolate bar Nice try. The average small movie popcorn with "buttery" topping has about 600 calories, about the same as a quarter pound cheeseburger (550 calories). A slice of thin crust cheese pizza Nice try.

    Les rapports seront ajouts Cheap Oakley Sunglasses la Longchamp Soldes Destockage liste officielle une fois le concours termin, ceux ci seront nanmoins toujours ligibles la suppression si leur score tombe 3.Si vous avez moins de trois rapports votre actif, il vous faudra l'accord d'un membre du staff pour publier votre article. Le principe est simple, la Classe Sr quivaut au tirage de deux tags, la Ray Ban Sale UK Classe Euclide de trois tags, la Classe Keter de quatre et enfin, pour les plus coriaces d'entre Bolsos Michael Kors Baratos vous, la Classe Apollyn de six tags!La classe choisie ne reprsente que le niveau de difficult, et ne dtermine pas la classe de votre objet SCP. Vous pouvez ainsi tout fait crer un objet de classe "Sr" alors que vous concourez dans la catgorie "Apollyn".Un vainqueur sera dsign dans chaque catgorie, alors n'ayez pas les yeux plus gros que le ventre et soyez raliste par rapport votre exprience, je vous garantis qu'un rapport six tags sera une preuve complexe.Dans le cas ou un participant jugerait ses tags trop incompatibles ou n'arriverait pas trouver d'inspiration avec ceux qui lui ont t attribu, il sera autoris demander un nouveau tirage.

    ReplyDelete
  4. Both things are possible if you carry Michael Kors Handbags Wholesale. If you are a woman who goes for innovative designs, a designer Michael Kors Bags On Sale is perfect for you. Offering a huge selection of chic purses, handbags, shoes and accessories, Michael Kors Outlet Online Store celebrates womanhood in an entirely unique way. Michael Kors Factory Outlet Online Store At Wholesale Price are one of the most sought-after handbags worldwide. We all agree that diamonds are a woman's best friend; however Official Coach Factory Outlet Online are absolutely next in line. To Coach Outlet Sale aficionados, don't fret because we have great news: a discount Official Coach Outlet Online isn't hard to find. If you are a smart shopper looking for a good buy and great deals on your next handbag purchase, you can go to Official Coach Outlet Online.

    Friendly Links: Toms Shoes Womens | Toms Clearance

    ReplyDelete
  5. dengan memiliki rasa coklat permen soloco sangat cocok bisa menambah suasana romantis yang mendalam saat bercinta bersama pasangan. baca tautan . wanita membutuhkan durasi yang lama saat berhubungan badan, obat luar seperti hajar jahanam cair obat kuat original bisa mencegah terjadinya ejakulasi dini yang terlalu cepat jadi bisa menambah kepuasan dalam bercinta bersama pasangan. klik disini . satu lagi obat luar jenis cream yang sekarang ini banyak diburu seperti cream stud 007 obat kuat aman yang sekaligus dapat digunakan sebagai gel pelicin sebelum berhubungan intim agar mempermudah masuknya saat penetrasi. info selengkapnya . besar dan panjangnya ukuran alat kelamin pria bisa menambah kepuasan wanita secara maksimal dengan cara menggunakan terapi pro extender secara rutin akan mendapatkan hasil yang maksimal.

    ReplyDelete
  6. I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts. Python Projects for Students Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account. Project Center in Chennai

    ReplyDelete