Fitness Cost Analysis using Device_Tracker

So I just finished up one of my first projects. I have been wondering how to determine what it costs me every time I go to my CrossFit gym using the formula

monthly_dues / attendance (i.e. $125 / 22 = cost per visit )

but I wanted it to be a more comprehensive log of entrance and exits into and out of defined zones so I could use a pivot table to create reports for all defined zones. How many times I go to Costco, how often I fuel up at various locations, how many times I go to church or the gym, etc.

Rather than set up an automation for each zone, I created a simple script that triggers a recipe at IFTTT and inserts 3 pieces of data captured from Home Assistant plus the available “OccurredAt” ingredient. IFTTT only allows 3 values in the ingredients, and then created two automations that utilize that script.

  • Value1: The friendly name of the device that triggers the action.
  • Value2: The location that the iPhone just left.
  • Value3: The location that the iPhone just entered.

The 2nd automation reverses the process by changing the trigger. One automation’s trigger is a state trigger
from: 'not_home' and the other is a state trigger to: 'not_home'.

With the data collected, I can create a pivot table to analyze it.

https://github.com/arretx/HASSIO/

Feel free to browse the repo under the automation/IFTTT folder and the /config/scripts folder.