Hey Smart home people, I wanted to share a little project I made to help with my weight loss journey.
There is just one prerequisite, I use the gamin connect integration which is linked to MyFitnessPal.
I made 2 number helpers:
- maintenance calories (mine is 2500)
- current weight
First I made some sensors which calculate daily weight loss, assuming there are 7700 calories in a Kg of Bodyfat:
consumed_calories - maintenance_calories / 7700
so, if daily I consume only 2000 calories, theoretically I would lose 0.07kg (70g) a day.
- platform: template
sensors:
weight_loss_nils_food_kg:
friendly_name: "Nils Weight Loss food"
value_template: "{{ ((states('sensor.consumed_kilocalories') | float(0) - states('input_number.nils_calories_maintenance') | float) / 7700 ) | round(2) }}"
unit_of_measurement: 'kg'
I added a second sensor which also takes in the “active” calories:
- platform: template
sensors:
weight_loss_nils_active_kg:
friendly_name: "Nils Weight Loss with activity"
value_template: "{{ (((states('sensor.consumed_kilocalories') | float(0)) + (states('sensor.active_kilocalories_kilocalories') | float(0)) - states('input_number.nils_calories_maintenance') | float) / 7700) | round(2) }}"
unit_of_measurement: 'kg'
Lastly I made to sensors to show the weight after the day’s loss and a silly one to show the remaining calories to reach my weight goal:
- platform: template
sensors:
weight_after_loss_nils_food_kg:
friendly_name: "Nils Weight After Loss Food"
value_template: "{{ (states('input_number.nils_current_weight') | float + states('sensor.weight_loss_nils_food_kg') | float(0)) }}"
unit_of_measurement: 'kg'
Total remaming Kcal:
- platform: template
sensors:
nils_remaining_calories_to_goal:
friendly_name: "Remaining Calories to Goal"
value_template: "{{ ((states('input_number.nils_actual_weight_placeholder') | float(0) - states('sensor.nils_withings_weight_goal') | float(0)) * 7700) | round(0) }}"
unit_of_measurement: 'kcal'