Sunday, January 10, 2016

Update on the journey to Mount Doom via FitBit

I know I just posted about this yesterday, but I've put some more work into this (while procrastinating other things, naturally).  To recap from yesterday, this is what I wanted to accomplish in "Day 2":

  1. Figure out where IFTTT adds the next row of data (i.e. above or below the first row?)
  2. Confirm the distance in miles from Hobbiton to Mount Doom in Miles, convert to Kilometres
  3. Take the task I started yesterday, and put it together with a task to tell me how many kilometres I've travelled, and how many I have left to go.
I'll tackle these in order here...

#1 was important because I needed to determine how I was pulling the data from Google Sheets.  In my task yesterday, I was just pulling R1C6, which in my spreadsheet translates to F1.  IFTTT adds the next row of data below the original row, rather than pushing it to the top (see here).  So this means my task works for January 8th - but for the 9th, I need to pull R2C6 (F2), R3C6 for Jan 10th, and so on.  

So I created a test sheet with 10 rows of data to use.  Then I created a task to add 1 to a variable (%Rownumber).  Without going into too many details, I set a variable called %Frow to R%RownumberC6.  I set %Rownumber to 0 initially so that the first time it runs, I'd get R1C6.  Simple!  

For #2, I found this website (appropriately called Nerd Fitness).  I don't know where this person got their numbers, but a second source confirming 1779 miles is good enough for me.  There's also a breakdown of how many miles between each stop, and number of miles for the return journey - but I need to get to Mount Doom first, so I'll come back to that later.  1779 miles = 2863 kilometres.  

#3 was a bit easier, since I already had the task to pull the data completed.  I just changed "R1C6" to "%Frow" - which means that it will change to R2C6, R3C6, etc. as needed.  Another task called "Distance" does a couple things: 

  • Sets the distance travelled (%DistanceTravelled) to "%DistanceTravelled + %Kms" (%Kms is set in "Get Kilometres", which is the task I described above)
  • Sets %RemainingDistance to "2863 - %DistanceTravelled"
After that, I put it all together into one task called "Display" that runs each task in order, and then sends it to a notification.  Here's a screenshot: 

I'm going to have to change the message to say "yesterday" instead of "today" - since it's not in real time (it would be if I could directly access the FitBit API...).  I don't know where that leaf icon comes from but it's a built-in icon, and I thought it was appropriate for this.  

Next on the to-do list: 
  • Figure out how to automate this process (I get a notification when IF updates the spreadsheet, so that could be the trigger)
  • Figure out how to incorporate the distances between towns (i.e. Hobbiton to Rivendell is 737.1km, etc.).
I think once I get those two things done, that's pretty much where I'm going to leave it.  One thing that I could do for posterity is add each update to a text file.  That's a pretty easy thing to do - I think I might just add that step tomorrow when I test the automation process.

No comments:

Post a Comment