vmanuel / hacs-google-fit

♥️ HACS Google Fit integration for Home Assistant
MIT License
53 stars 21 forks source link

Cannot read HeartRate BPM (others work OK) #12

Closed GuyKh closed 1 year ago

GuyKh commented 3 years ago

Getting this in the logs:

2021-05-13 10:55:05 WARNING (SyncWorker_5) [googleapiclient.http] Encountered 403 Forbidden with reason "forbidden"
2021-05-13 10:55:05 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 365, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 482, in async_device_update
    await task
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 278, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 278, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/google_fit/sensor.py", line 517, in update
    for datapoint in self._get_dataset_from_last_update(self.DATA_SOURCE)["point"]:
  File "/config/custom_components/google_fit/sensor.py", line 308, in _get_dataset_from_last_update
    return self._client.users().dataSources(). \
  File "/usr/local/lib/python3.8/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/googleapiclient/http.py", line 842, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://fitness.googleapis.com/fitness/v1/users/me/dataSources/derived%3Acom.google.heart_rate.bpm%3Acom.google.android.gms%3Amerge_heart_rate_bpm/datasets/1620852120000000000-1620892504000000000?alt=json returned "Cannot read data of type com.google.heart_rate.bpm">

In the Google API I've got the scope of heartRate.read and heartRate.write enabled and all.

Configuration:

sensor:
  - platform: google_fit
    name: Google Fit
    client_id: !secret google_client_id
    client_secret: !secret google_client_secret
ranrinc commented 3 years ago

API is update since May 5, need some changes on the scripts

TarheelGrad1998 commented 3 years ago

+1

FWIW - I'm not using the sensor anyway, so for now I have just commented line 191 in sensor.py on my local: # GoogleFitHeartRateSensor(client, name),

wasden76 commented 3 years ago

+1

vmanuel commented 1 year ago

I have not maintained this repository for a long time. I think the HACS from https://github.com/YorkshireIoT/ha-google-fit is perfect