Google Fit Support

I’m getting this error on a clean install that’s been authorized.

2019-09-30 14:47:17 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
...
  File "/config/custom_components/google_fit/sensor.py", line 330, in _get_dataset
    return self._client.users().dataSources(). \
AttributeError: 'NoneType' object has no attribute 'users'

I’m using the config you mentioned in the post I’m replying to. Where does the ‘name’ field come from is it a local name or does it need to match something in google?

EDIT: Simply needed a restart to work

for some reason im not seeing the sleep sensor information coming through. Any suggestions?

Yeah, me too. I had it come up briefly after first connecting, however today (the next day) the state is empty. Tried restarting HA to no real effect

Hi. I installed this component, made token. Sensors appeared in HA, but they are all empty, besides height and weight. So it looks like token is good. But why they didn’t fetch data? Three days pass throw, but sensors still show nulls. Any guess?

@Crickus
Did you manage to get it working? i’m still having exactly the same issue.
Are you using Google Suite like me by coincidence?

Yep. It sounds stupid, but all synchronization between third-party apps and Google fit works locally. Because of closing web interface for Google fit in March synchronization starts with Google fit locally and when Google fit synchronize data with online servers. So you need Google fit been active on your phone, but I just deleted it after making profile. What was my problem. I’m not sure about your situation.

Like other people am also having some issues with this component .

Doesn’t seem like it’s really updating any data besides pre defined weight and height …

Based on

and a few changes in GoogleFitHeartRateSensor, I created

2 Likes

would there be any way to get the “resting heart rate” that is displayed in google fit at all? Thanks!

anyone else had this error?

2019-12-12 20:34:36 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 292, in _async_add_entity
await entity.async_device_update(warning=False)
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 450, in async_device_update
await self.hass.async_add_executor_job(self.update)
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/homeassistant/homeassistant/util/init.py”, line 240, in wrapper
result = method(*args, **kwargs)
File “/usr/src/homeassistant/homeassistant/util/init.py”, line 240, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/google_fit/sensor.py”, line 443, in update
last_time_update = time_updates[0]
IndexError: list index out of range

I think it is fixed (not cheed jet. I think that error occus the first call after 00:00).

1 Like

@vmanuel I believe your lastest release version mispelled the custom_components/google_fit/ with custom_components/google-fit/ which create an error.

@mathewtaylor2007 I hope you will be able to fixed it…

1 Like

Done (v1.1.4)

It is possible you have to uninstall the integration, remove the repo and reinstall it again.

Is there any way to change the measurement units from metric to imperial for us ‘freedom unit’ impaired folks? I’m sure it could be done with templates, but it seems like the sensor should use the HA unit_system setting.

1 Like

I’m getting the following error:

2020-04-18 19:26:52 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
Traceback (most recent call last):
  File "C:\Python38\lib\site-packages\homeassistant\helpers\entity_platform.py", line 312, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "C:\Python38\lib\site-packages\homeassistant\helpers\entity.py", line 476, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "C:\Python38\lib\concurrent\futures\thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Python38\lib\site-packages\homeassistant\util\__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "C:\Python38\lib\site-packages\homeassistant\util\__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "C:\Users\stefa\AppData\Roaming\.homeassistant\custom_components\google_fit\sensor.py", line 396, in update
    height_datasources = self._get_datasources('com.google.height')
  File "C:\Users\stefa\AppData\Roaming\.homeassistant\custom_components\google_fit\sensor.py", line 303, in _get_datasources
    datasources_request = self._client.users().dataSources().list(
AttributeError: 'NoneType' object has no attribute 'users'

I tried to remove the pycache and restart, but the error is still the same…

After restarting HomeAssistant, you should se a notification such as:

In order to authorize Home-Assistant to view your Google Fit data you must visit: https://www.google.com/device and enter code: XXXX-XXXX

After following this step and restarting Home Asssistant, no errors in the log. Eyerything works fine.

“Freedom Unit” template sensor templates if still needed:

- platform: template
  sensors:
    sensor_weight:
      friendly_name: "weight"
      unit_of_measurement: 'lbs'
      value_template: "{{ (states('sensor.sensor_weight') | float * 2.20462262185) | round }}"
      icon_template: mdi:weight-pound
- platform: template
  sensors:
    sensor_distance:
      friendly_name: "distance"
      unit_of_measurement: 'mi'
      value_template: "{{ (states('sensor.sensor_distance') | float / 1.609) | round(2) }}"
      icon_template: mdi:map-marker-distance  
2 Likes

This works great, I’m digging it a lot! Hopefully this post helps anyone facing syncing issues… I use Fitbit and ended up needing to utilize a third party app to push my data over to Google Fit called FitToFit. Worked wonders syncing everything nice and easy, although I’m sure google will eventually make the sync more streamlined if they ever close on the Fitbit acquisition… FittoFit worked as an interim solution for me.

Disclaimer: I’m a total novice at this but if I can do it anyone can, hopefully the config can keep inspiring others as you have inspired me!

cards:
      - type: picture-elements
        title: Google Fit
        elements:
          - type: image
            image: /local/g_f.png
            style:
              width: 70%
              top: 50%
              left: 50%
              filter: blur(3px) brightness(80%)
          - type: state-label
            entity: sensor. s_calories
            style:
              top: 40%
              left: 50%
              font-size: 14px
              filter: brightness(140%)
          - type: state-icon
            entity: sensor. s_calories
            style:
              top: 20%
              left: 47%
              '--iron-icon-height': 70px
              '--iron-icon-width': 70px
              '--paper-item-icon-color': white
          - type: state-label
            entity: sensor. s_weight
            style:
              top: 80%
              left: 50%
              font-size: 14px
              filter: brightness(140%)
          - type: state-icon
            entity: sensor. s_weight
            style:
              top: 60%
              left: 47%
              '--iron-icon-height': 70px
              '--iron-icon-width': 70px
              '--paper-item-icon-color': white
          - type: state-label
            entity: sensor. s_sleep
            style:
              top: 80%
              left: 83%
              font-size: 14px
              filter: brightness(140%)
          - type: state-icon
            entity: sensor. s_sleep
            style:
              top: 60%
              left: 80%
              '--iron-icon-height': 70px
              '--iron-icon-width': 70px
              '--paper-item-icon-color': white
          - type: state-label
            entity: sensor. s_heart_rate
            style:
              top: 80%
              left: 18%
              font-size: 14px
              filter: brightness(140%)
          - type: state-icon
            entity: sensor. s_heart_rate
            style:
              top: 60%
              left: 15%
              '--iron-icon-height': 70px
              '--iron-icon-width': 70px
              '--paper-item-icon-color': white
          - type: state-label
            entity: sensor. s_steps
            style:
              top: 40%
              left: 18%
              font-size: 14px
              filter: brightness(140%)
          - type: state-icon
            entity: sensor. s_steps
            style:
              top: 20%
              left: 15%
              '--iron-icon-height': 70px
              '--iron-icon-width': 70px
              '--paper-item-icon-color': white
          - type: state-label
            entity: sensor. s_move_time
            style:
              top: 40%
              left: 83%
              font-size: 14px
              filter: brightness(140%)
          - type: state-icon
            entity: sensor.s_move_time
            style:
              top: 20%
              left: 80%
              '--iron-icon-height': 70px
              '--iron-icon-width': 70px
              '--paper-item-icon-color': white
        image: /local/gradient_background_1440x900_24bit.png
      - type: vertical-stack
        cards:
          - type: horizontal-stack
            cards:
              - type: sensor
                entity: sensor. s_move_time
                graph: line
                name: Move Time
              - entities:
                  - entity: sensor. s_steps
                    name: Steps
                hours_to_show: 168
                line_color:
                  - yellow
                icon: 'mdi:walk'
                refresh_interval: 0
                type: 'custom:mini-graph-card'
          - type: horizontal-stack
            cards:
              - entities:
                  - entity: sensor. s_heart_rate
                    name: Heart Rate
                hours_to_show: 24
                line_color:
                  - green
                icon: 'mdi:heart'
                refresh_interval: 0
                type: 'custom:mini-graph-card'
              - entities:
                  - entity: sensor. s_calories
                    name: Calories
                hours_to_show: 24
                line_color:
                  - red
                icon: 'mdi:food'
                refresh_interval: 0
                type: 'custom:mini-graph-card'
          - type: horizontal-stack
            cards:
              - entities:
                  - entity: sensor. s_move_time
                    name: Move Time
                hours_to_show: 24
                line_color:
                  - orange
                icon: 'mdi:clock-outline'
                refresh_interval: 0
                type: 'custom:mini-graph-card'
              - type: sensor
                entity: sensor.s_sleep
                name: Sleep
    icon: 'mdi:google-fit'
    path: google-fit
    title: Google Fit
6 Likes

Where can i find the repo for this custom component?

I used this: https://github.com/vmanuel/hacs-google-fit