Something neat I did with FitNotes and Tasker
I use the fitness tracking app FitNotes on Android. It's a great application that I have happily used for years. The greatest issue I had with it was manually entering my body weight. Well I finally got myself into gear and fixed that issue using the fantastic staple of Android automation, Tasker
Using a Xiaomi Mi Smart Scale that I hooked up to my home server using my python gatttool wrapper I Dump it's weight data into a Google spreadsheet.
Using my Simple API (Because Google's own API is a pain) and the helper task getformatteddate, I pull a unix timestamp and the weight onto my Phone. I then run a
INSERT SQL command on FitNote's database (using root of course)
I also did a bulk body weight record import via
.csv using sqlitebrowser. Now I no longer have to manually enter my body weight, should have done this years ago.
Here is my Tasker task if you are interested:
Healthapi (44) A1: Flash [ Text:%date %time Long:Off ] A2: Flash [ Text:Updating Health Report Long:Off ] A3: HTTP Get [ Server:Port:https://script.google.com Path:/macros/s/myprivatesheet/exec Attributes:key=myapikey Cookies: User Agent: Timeout:20 Mime Type: Output File: Trust Any Certificate:Off ] A4: Variable Set [ Name:%data To:%HTTPD Recurse Variables:Off Do Maths:Off Append:Off ] A5: Variable Set [ Name:%newline To: Recurse Variables:Off Do Maths:Off Append:Off ] A6: Variable Split [ Name:%data Splitter:%newline Delete Base:Off ] A7: Variable Split [ Name:%data1 Splitter:, Delete Base:Off ] A8: Read File [ File:Tasker/lastdate.dat To Var:%lastdate Continue Task After Error:On ] A9: If [ %lastdate neq %data11 ] A10: Write File [ File:Tasker/lastdate.dat Text:%data11 Append:Off Add Newline:Off ] A11: Perform Task [ Name:getFormattedDate Priority:%priority Parameter 1 (%par1):%data11 Parameter 2 (%par2):yyyy-mm-dd Return Value Variable:%date Stop:Off ] A12: Perform Task [ Name:getFormattedDate Priority:%priority Parameter 1 (%par1):%data11 Parameter 2 (%par2):hh:nn:ss Return Value Variable:%time Stop:Off ] A13: Variable Set [ Name:%measurement_id To:1 Do Maths:Off Append:On ] A14: Variable Set [ Name:%value To:%data12 Do Maths:Off Append:On ] A15: Variable Set [ Name:%query To:INSERT INTO MeasurementRecord (measurement_id, date, time, value, comment) VALUES ("%measurement_id", "%date", "%time", "%value",""); Do Maths:Off Append:Off ] A16: SQL Query [ Mode:Raw File:/data/data/com.github.jamesgay.fitnotes/databases/database.db Table: Columns: Query:%query Selection Parameters: Order By: Output Column Divider: Variable Array:%test Use Root:On ]
I hope you found this interesting, if only in the abstract "hey that's a thing you can totally do" kind of way. If you want me to write a complete how-to let me know in the comments down below.