Google Fit Support

Xiaomi Scale 2


Google Fit:

Smart Band (Denver bhf 240) connect with google fit
https://g.co/kgs/Z9kHbc

Lovelace:
cards:

  • entities:

    • entity: sensor.alex
      name: Gewicht
    • entity: person.alexander
      name: ’ ’
      show_state: false
    • entity: sensor.alex_bmi
      icon: ‘mdi:human’
      name: BMI
      no_card: true
      show_header_toggle: false
      style: |

    ha-card {

    margin: 1rem 0.5rem;

    -webkit-box-shadow: 0px 3px 6px 3px rgba(0,0,0,0.48);

    -moz-box-shadow: 0px 3px 6px 3px rgba(0,0,0,0.48);

    box-shadow: 0px 3px 6px 3px rgba(0,0,0,0.48);

    }
    type: glance

  • elements:

    • color_stops:
      ‘1’: ‘#09C7E8
      ‘10000’: ‘#0BDF0E
      entity: sensor.google_fit_distance
      fill: ‘#1250
      font_style:
      font-color: white
      font-size: 1em
      text-shadow: 0.4px 0.4px black
      gradient: true
      max: 10
      min: 0
      name: Distanz
      show_card: false
      stroke_color: green
      stroke_width: 10
      style:
      height: 85px
      left: 75%
      top: 10%
      transform: none
      width: 85px
      type: ‘custom:circle-sensor-card’
      units: km
    • color_stops:
      ‘1’: ‘#09C7E8
      ‘10000’: ‘#0BDF0E
      entity: sensor.google_fit_steps
      fill: ‘#1250
      font_style:
      font-color: white
      font-size: 1em
      text-shadow: 2px 2px black
      gradient: true
      max: 10000
      min: 0
      name: Schritte
      show_card: false
      stroke_color: green
      stroke_width: 10
      style:
      height: 85px
      left: 5%
      top: 10%
      transform: none
      width: 85px
      type: ‘custom:circle-sensor-card’
      units: ’ ’
    • entity: sensor.google_fit_calories
      fill: ‘#1250
      font_style:
      font-color: white
      font-size: 1em
      text-shadow: 2px 2px black
      gradient: true
      max: 1000
      min: 0
      name: Kalorien
      show_card: false
      stroke_color: red
      stroke_width: 5
      style:
      height: 85px
      left: 5%
      top: 45%
      transform: none
      width: 85px
      type: ‘custom:circle-sensor-card’
      units: kcal
    • color_stops:
      ‘1’: ‘#09C7E8
      ‘30’: ‘#0BDF0E
      entity: sensor.google_fit_move_time
      fill: ‘#1250
      font_style:
      font-color: white
      font-size: 1em
      text-shadow: 2px 2px black
      gradient: true
      max: 30
      min: 0
      name: Aktivität
      show_card: false
      stroke_color: red
      stroke_width: 5
      style:
      height: 82px
      left: 75%
      top: 45%
      transform: none
      width: 90px
      type: ‘custom:circle-sensor-card’
      units: min
    • entity: sensor.google_fit_heart_rate
      style:
      color: white
      left: 42%
      top: 65%
      transform: none
      type: state-label
      image: /local/images/googlefitmaterialup.png
      no_card: true
      style: |

    ha-card {

    margin: 0rem 0rem;

    -webkit-box-shadow: 0px 3px 6px 3px rgba(0,0,0,0.48);

    -moz-box-shadow: 0px 3px 6px 3px rgba(0,0,0,0.48);

    box-shadow: 0px 3px 6px 3px rgba(0,0,0,0.48);

    }
    type: picture-elements

  • entities:

    • sensor.google_fit_heart_rate
      font_size: 100
      icon: ‘mdi:heart-pulse’
      line_color: red
      line_width: 2
      name: Puls
      no_card: true
      style: |

    ha-card {

    margin: 1rem 0.5rem;

    -webkit-box-shadow: 0px 3px 6px 3px rgba(0,0,0,0.48);

    -moz-box-shadow: 0px 3px 6px 3px rgba(0,0,0,0.48);

    box-shadow: 0px 3px 6px 3px rgba(0,0,0,0.48);

    }
    type: ‘custom:mini-graph-card’
    unit: BPM
    type: vertical-stack

2 Likes

Hi, would you be able to share this formatted?

cards:
  - entities:
      - entity: sensor.alex
        name: Gewicht
      - entity: person.alexander
        name: ' '
        show_state: false
      - entity: sensor.alex_bmi
        icon: 'mdi:human'
        name: BMI
    no_card: true
    show_header_toggle: false
    type: glance
  - elements:
      - color_stops:
          '1': '#09C7E8'
          '10000': '#0BDF0E'
        entity: sensor.google_fit_distance
        fill: '#1250'
        font_style:
          font-color: white
          font-size: 1em
          text-shadow: 0.4px 0.4px black
        gradient: true
        max: 10
        min: 0
        name: Distanz
        show_card: false
        stroke_color: green
        stroke_width: 10
        style:
          height: 85px
          left: 75%
          top: 10%
          transform: none
          width: 85px
        type: 'custom:circle-sensor-card'
        units: km
      - color_stops:
          '1': '#09C7E8'
          '10000': '#0BDF0E'
        entity: sensor.google_fit_steps
        fill: '#1250'
        font_style:
          font-color: white
          font-size: 1em
          text-shadow: 2px 2px black
        gradient: true
        max: 10000
        min: 0
        name: Schritte
        show_card: false
        stroke_color: green
        stroke_width: 10
        style:
          height: 85px
          left: 5%
          top: 10%
          transform: none
          width: 85px
        type: 'custom:circle-sensor-card'
        units: ' '
      - entity: sensor.google_fit_calories
        fill: '#1250'
        font_style:
          font-color: white
          font-size: 1em
          text-shadow: 2px 2px black
        gradient: true
        max: 1000
        min: 0
        name: Kalorien
        show_card: false
        stroke_color: red
        stroke_width: 5
        style:
          height: 85px
          left: 5%
          top: 45%
          transform: none
          width: 85px
        type: 'custom:circle-sensor-card'
        units: kcal
      - color_stops:
          '1': '#09C7E8'
          '30': '#0BDF0E'
        entity: sensor.google_fit_move_time
        fill: '#1250'
        font_style:
          font-color: white
          font-size: 1em
          text-shadow: 2px 2px black
        gradient: true
        max: 30
        min: 0
        name: Aktivität
        show_card: false
        stroke_color: red
        stroke_width: 5
        style:
          height: 82px
          left: 75%
          top: 45%
          transform: none
          width: 90px
        type: 'custom:circle-sensor-card'
        units: min
      - entity: sensor.google_fit_heart_rate
        style:
          color: white
          left: 42%
          top: 65%
          transform: none
        type: state-label
    image: /local/images/googlefitmaterialup.png
    no_card: true
    type: picture-elements
  - entities:
      - sensor.google_fit_heart_rate
    font_size: 100
    icon: 'mdi:heart-pulse'
    line_color: red
    line_width: 2
    name: Puls
    no_card: true
    type: 'custom:mini-graph-card'
    unit: BPM
type: vertical-stack

2 Likes

I haven’t been able to figure out how to use any of these custom components with multiple Google accounts. The hemantkamalakar mod says it supports this, but maybe I misunderstand what this means. I would like to be able to include data from several immediate family members, but have not found a way to format things such that HA creates functioning sensors for more than one user.

1 Like

Ok, so I am probably doing something obviously wrong but I can’t get the Google Fit sensor added.

Here’s steps to reproduce:

  1. Running Home Assistant Core 0.118.5 on a raspberry pi 3
  2. I have downloaded and installed hemants files from here: https://github.com/hemantkamalakar/google_fit_hass
  3. Downloaded ‘custom_components’ has been placed inside the config folder
  4. Added configuration to configurations.yaml:
sensor:  
  - platform: google_fit
    name: Carsten
    client_id: -myid-
    client_secret: -mysecret-
    scan_interval: 300
  1. When trying to verify the config file before restarting I get the following error:

Platform error sensor.google_fit - Integration ‘google_fit’ not found.

Does anyone know what I am doing wrong?

Edit: Most recent version of these files require the sensor to be called google_fit_hass and not just google_fit :slight_smile: It was even in the readme (though not the documentation)

Edit2: I waited the 6 hours after adding the sensor but nothing shows up in HA, any suggestions?

Could someone add support for reading bloodpressure?

Were you able to get multiple users? I’m trying to do the same. I’ve added another email as a test user and created a seperate Oauth credentials, but I’m not able to get the notification to add the device code

Managed to create multiple users in a lazy way: made another OAuth stuff and created another integration named Fit2- copied existing folder to another one and changed the integration names to e.g. GFit2 and created another binding in configuration.yaml with second user credentials.
Dirty but works OK :slight_smile:
Best, JR

2 Likes

Worked great! Thank you!

I haven’t managed to get Google Fit integration from HACS to work (https://github.com/cyberjunky/home-assistant-google_fit). Installation from HACS worked fin, but as soon as i add the sensor info i get an error in HA after restart. The message is:

Google Fit Setup

Error: Invalid response 401. Error: invalid_client
You will need to restart hass after fixing.

When i configured Oauth Consent Screen and filled in my gmail-address as test-user i got a warning from Google. Se screenshot

Would appreciate if someone could help me in the right direction how to make the integration work.

This is solved. I had to create a new Oauth key and choose “Desktop” as type. Other is no longer availible as mentioned in other threads

hi everyone, i created the integration with google fit and everything worked. I find the sensors, but there is a problem; they are not updated with respect to the data on the application. can someone help me?

I’ve tried doing this but it’s picking up the data from just one Google Fit account. How did you deal with the token to get two accounts to work?

Modified the sensor.py to something like that for another account:

# Sensor details.
SENSOR = 'google_fit_2'

# Sensor base attributes.
ATTR_LAST_UPDATED = 'last_updated'
CONF_CLIENT_ID = 'client_id'
CONF_CLIENT_SECRET = 'client_secret'
DEFAULT_NAME = 'Google Fit 2'
DEFAULT_CREDENTIALS_FILE = '.google_fit.credentials_2.json'
ICON = 'mdi:heart-pulse'
MIN_TIME_BETWEEN_SCANS = timedelta(minutes=10)
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=10)
TOKEN_FILE = '.{}.token'.format(SENSOR)
SENSOR_NAME = '{} {}'

and of course two separate sensors: one with platform: google_fit and another with google_fit_2 …
Best, JR

Did exactly what you’ve said (I think) but it’s only asking to verify the one set of credentials … then in both the sensors showing the same data…

My guess is that You are stuck in Google OAuth stuff?
Different game :frowning:
Best, JR

Got it!

Changed the manifest.json domain to “google_fit2” and it works :slight_smile:

Good for us :slight_smile:
Stay wealthy… and fit
Best, JR

Thanks man… I wonder if something similar can be done with the Strava integration as the wife and I both use it…

I guess so- install it in different folder under custom_components as e.g. Brava and tinker/configure via UI as usual :slight_smile:
Best, JR

Any recommendation on which one to use?