Where do you put your health metrics?

If you integrate your Fitbit, Withings, etc. data into Home Assistant…where do you put it? Do you create an area called “Nickduino”? A “Nickduino Health” area?

I tried the Strava integration, and used several gague cards to track day of year against distance goals.

You get base unit types (distance, time, count, etc) but that’s about it. I guess you could define helper entities with input boxes and log into long-term stats for graphing, but not out of the box.

Ultimately the yearly totals for cycling and running didn’t work for me due to a Strava API issue not counting Zwift distance and under-reporting (not the HASS integration’s fault).

Can you share your code for the gauges? I am looking for a way to show month to date total, or how much left to go to meet my goal. I’d also like to see my progress towards my yearly goal.

This is on a tablet on my desk, I recently added my weight to shame myself into not eating cookies for breakfast.

In what “area” do you put them?
If you integrate Fitbit and Google Fit, do you put them in the same area or in two separate ones? What are the advantages of one or the other solution?

The code was removed from production after finding the Strava API undercount, but here’s the old version.

It is basically percentage entities - year %, run %, ride % all calculated once per day. Input helpers create a means of entering the targets, which are then calculated against the current date (something Strava wants Premium subs to graph for you).

These can them be added to the same gauge card to show 0-99 tracking time against the goals which are entered.

These are all template entities, so I use a separate templates.yaml file:

# templates.yaml
# no "template:" here as in configuration.yaml

- trigger:
    - event: start
      platform: homeassistant
    - platform: event
      event_type: event_template_reloaded
    - platform: time_pattern
      # only needs to change once a day
      hours:   05
      minutes: 05
  unique_id: 123456789012
  sensor:
    - name: Date in Text
      #description: "Date in text format suitable for TTS"
      state: >
          {% set dayofweek = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][now().weekday()] %}
          {% set day = ['1st','2nd','3rd','4th','5th','6th','7th','8th','9th','10th','11th','12th','13th','14th','15th','16th','17th','18th','19th','20th','21th','22th','23th','24th','25th','26th','27th','28th','29th','30th','31th' ][ now().day-1] %}
          {% set month = ['January','February','March','April','May','June','July','August','September','October','November','December'][now().month-1] %}
          {{ dayofweek +', '+ day + ' ' + month + ' '+ now().strftime('%Y') }}
      icon: "mdi:CalendarRange"

# Strava integration template entities to calculate annual goal progress
    - name: YTD Percent
      state: "{{ ((as_timestamp(now().date()) - as_timestamp('2023-01-01')) / 86400 / 365.25 * 100)|round(1,'ceil') }}"
      #state_class: "measurement"
      icon: "mdi:percent"
      unique_id: 10000001

    - name: YTD Ride Percent
      state: "{{ (((states('sensor.strava_stats_summary_ytd_ride_distance')|float / states('input_number.year_ride_target')|float) *100) |round(1,'ceil')) }}"
      #state_class: "measurement"
      icon: "mdi:percent"
      unique_id: 10000002

    - name: YTD Ride Target
      state: "{{ ((as_timestamp(now().date()) - as_timestamp('2024-01-01')) / 86400 / 365.25 * states('input_number.year_ride_target')|round(0,'ceil'))|round(1,'ceil') }}"
      #state_class: "measurement"
      icon: "mdi:percent"
      unique_id: 10000003

    - name: YTD Run Percent
      state: "{{ (((states('sensor.strava_stats_summary_ytd_run_distance')|float / states('input_number.year_run_target')|float) *100) |round(1,'ceil')) }}"
      #state_class: "measurement"
      icon: "mdi:percent"
      unique_id: 10000004

    - name: YTD Run Target
      state: "{{ ((as_timestamp(now().date()) - as_timestamp('2023-01-01')) / 86400 / 365.25 * states('input_number.year_run_target')|round(0,'ceil'))|round(1,'ceil') }}"
      #state_class: "measurement"
      icon: "mdi:percent"
      unique_id: 10000005

If this helps, :heart: this post!

1 Like

This is cool, let me dig into this and see if I can figure it out. Thanks !

Hi,

To answer your question more directly, here’s a Number input helper from my own calculations:

  • Settings → Devices & Services → Helpers → Number


(notice the optimism with the Maximum value :slight_smile: :athletic_shoe: )

I’ve added similar fitness input numbers for yearly goals (e.g. year_run_target) as I found the Strava API didn’t produce accurate figures compared to the app / website (known issue - omits some ‘virtual’ Zwift stats).

Do you create an area called “Nickduino”? A “Nickduino Health” area?

Yes - a common area will link them together. I just used Test, rather than say Fitness or Health which might be better.

Obvious bug - the year start is hardcoded, so you’ll need to change '2023-01-01'. I should extend the template function to make this automatic.