Google Fit Support

Ok, getting the same errors at yours now!

'google_fit: Error on device update!
‘Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 261, in _async_add_entity
await entity.async_device_update(warning=False)
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 380, 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 224, in wrapper
result = method(*args, **kwargs)
File “/usr/src/homeassistant/homeassistant/util/init.py”, line 224, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/google_fit/sensor.py”, line 612, in update
sleep_dataset = self._client.users().sessions().list(userId=‘me’,fields=‘session’,startTime=starttime,endTime=endtime).execute()
AttributeError: ‘NoneType’ object has no attribute ‘users’’

Looks like there is a setting missing now that it supports multi-users

How does your sensor definition look like?
It should be something like

sensor:  
  - platform: google_fit
    name: hemant
    client_id: !secret google_client_id
    client_secret: !secret google_client_secret
    scan_interval: 300

By deleting the content of the pycache folder, I was able to enter my auth code and after a reboot, it works great. Thanks

Excellent news. Where’s the pycache folder located?

\config\custom_components\google_fit

Thanks, found it. Deleted, restarted, nothing.
Deleted the component, restarted, re-installed the component, sensors added.

Cheers!

@hemantkamalakar Hey, any way of changing weight to Lbs and Height to ft? And cm to ft and inch? :slight_smile:
Thanks

@godinperson You can try changing the units in Google fit App.

It’s already like I want in Google Fit. It’s like the integration picks up default value instead of my values.

Thanks

New error on 0.97

Error while setting up platform google_fit
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 149, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/google_fit/sensor.py", line 222, in setup_platform
    client = _get_client(token_file)
  File "/config/custom_components/google_fit/sensor.py", line 138, in _get_client
    http = credentials.authorize(httplib2.Http())
AttributeError: 'NoneType' object has no attribute 'authorize'

I need help setting this component up under 0.97.2.
I dropped the sensor.py file in custom_components/google_fit but my log says

Integration google_fit not found when trying to verify its sensor platform.
2:53 PM components/hassio/__init__.py (ERROR)

Drop an empty file called __init__.py in that same directory. The custom_component author hasn’t made this very clear.

tried that and authenticated/gave access through the notification but after several restarts it still doesn’t show any entities

Mine shows entities as sensor.GOOGLEFIT_SENSOR_NAME_steps (in my case, sensor.fit_daniel_steps).

If there aren’t any errors in the error log and it still isn’t adding these, try turning on debug logging and then restarting home assistant. That should show something.

I have not read the code changes that were made over my original gist, but in general, there are 3 files required:

  • __init__.py which is required for Python to define a module.
  • sensor.py which is required for Home Assistant to be able to implement this as a sensor.
  • manifest.json which I am unsure if it’s required, but basically gives metadata about the component.

If you delete them, I would not expect the component to work.

If you were trying to delete it, then delete all the files and the folder for the custom_componenent/google_fit. You may also need to find, within the config folder, the files for the Google credentials which are stored there. This would not affect the component as it won’t load without the folder, but it will ensure you have a fresh refresh if you ever re-install it.

@hemantkamalakar ? Any ideas why it stopped working on 0.97? We have to make that component an official one

I am running it on 0.97.2. I have recently added support for Heart rate sensor. This is how it looks:

Do you plan to add HACS support?

3 Likes

Just corrected my issue, if it can help others. In my config file, I had two hidden files .google.token. Deleted them and reboot solved the issue

Did you manage to convert the units?