Coder Social home page Coder Social logo

cyberjunky / home-assistant-google_fit Goto Github PK

View Code? Open in Web Editor NEW
99.0 13.0 21.0 22 KB

:hearts: This component tracks your Google Fit activities.

License: MIT License

Python 100.00%
home-assistant homeassistant custom-component hacs google-fit python

home-assistant-google_fit's Introduction

hacs_badge made-with-python Donate

NOTE: deprecated!

This integration is not maintained for Years, I suggest looking at this one: https://github.com/YorkshireIoT/ha-google-fit

Google Fit Sensor Component

Based on, with small fixes:

Creates Google Fit sensors. At the moment, the component provides following measurements:

  • steps
  • distance
  • time
  • calories
  • weight
  • height
  • sleep
  • heartrate

The sensors are designed to be flexible and allow customization to add new Google Fit dimensions with minimal effort with relative knowledge of Python and the Fitness Rest API.

Installation

HACS - Recommended

  • Have HACS installed, this will allow you to easily update.
  • Add https://github.com/cyberjunky/home-assistant-google_fit as a custom repository with Type: Integration
  • Click Install under "Google Fit" integration.
  • Restart Home-Assistant.

Manual

  • Copy directory custom_components/google_fit to your <config dir>/custom_components directory.
  • Configure.
  • Restart Home-Assistant.

Example configuration.yaml

In order to add this component as is, add a new sensor:

sensor:
  - platform: google_fit
    name: Google Fit
    client_id: your_client_id
    client_secret: your_client_secret

Client ID and Client Secret

In order to generate your client_id and client_secret, see the prerequisites for the Google Calendar component: https://www.home-assistant.io/components/calendar.google/#prerequisites To make sensor work you have to enable the Fitness API in your project. In oder to enable Fitness API open Google Cloud console: https://console.cloud.google.com/apis/library/fitness.googleapis.com and enable API.

It is recommendable to store the client_id and client_secret as securely as possible. You can read about it on: https://www.home-assistant.io/docs/configuration/secrets/

Example:

  - platform: google_fit
    name: Bob
    client_id: !secret google_fit_client_id
    client_secret: !secret google_fit_client_secret

FAQ

If you have issues authenticating or setup try this workaround first:

Set your HA timezone to (GMT+00:00) GMT (no daylight saving) then restart HA. You'll get a notification to Authenticate. Once the Auth with Google is complete, you can change your timezone back and restart.

Debugging

Add the relevant lines below to the configuration.yaml:

logger:
  default: info
  logs:
    custom_components.google_fit: debug

home-assistant-google_fit's People

Contributors

cyberjunky avatar michaelmior avatar paillom avatar wrt54g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

home-assistant-google_fit's Issues

googleapiclient.errors.UnknownApiNameOrVersion: name: fitness version: v1

It seems that this integration is no longer working with HASS 2022.4:

Traceback (most recent call last):
  File "/srv/hass/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/hass/.homeassistant/custom_components/google_fit/sensor.py", line 180, in setup_platform
    client = _get_client(token_file)
  File "/home/hass/.homeassistant/custom_components/google_fit/sensor.py", line 103, in _get_client
    service = google_discovery.build(
  File "/srv/hass/lib/python3.9/site-packages/googleapiclient/_helpers.py", line 131, in positional_wrapper
  File "/srv/hass/lib/python3.9/site-packages/googleapiclient/discovery.py", line 287, in build
    service = json.loads(content)
  File "/srv/hass/lib/python3.9/site-packages/googleapiclient/discovery.py", line 404, in _retrieve_discovery_doc
    if schema_type == 'string':
googleapiclient.errors.UnknownApiNameOrVersion: name: fitness  version: v1

Authentication code expired, please restart Home-Assistant and try again

Hello,
I've update the component to the lastert version 1.0.6 but the issue still persist.

Logger: homeassistant.components.sensor
Source: custom_components/google_fit/sensor.py:282
Integration: Capteur ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 12:51:55 (4 occurrences)
Last logged: 12:51:56
google_fit: Error on device update!

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in async_device_update
    await task
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 192, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 192, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/google_fit/sensor.py", line 488, in update
    for point in self._get_dataset(self.DATA_SOURCE)["point"]:
  File "/config/custom_components/google_fit/sensor.py", line 282, in _get_dataset
    return self._client.users().dataSources(). \
AttributeError: 'NoneType' object has no attribute 'users'
Logger: homeassistant.components.sensor
Source: custom_components/google_fit/sensor.py:247
Integration: Capteur ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 12:51:54 (2 occurrences)
Last logged: 12:51:55

    Error adding entities for domain sensor with platform google_fit
    Error while setting up google_fit platform for sensor

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 619, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 810, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 533, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 574, in _async_write_ha_state
    attr.update(self.extra_state_attributes or {})
  File "/config/custom_components/google_fit/sensor.py", line 247, in extra_state_attributes
    return self._attributes
AttributeError: 'GoogleFitWeightSensor' object has no attribute '_attributes'

I'm not able to authenticate.

google_fit: Error on device update!

I'm getting this in the logs while reinstalling the integration, after HA restarts. The client_id and secret are correct, I checked.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 477, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 702, in async_device_update
    await task
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 192, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 192, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/google_fit/sensor.py", line 490, in update
    for point in self._get_dataset(self.DATA_SOURCE)["point"]:
  File "/config/custom_components/google_fit/sensor.py", line 287, in _get_dataset
    execute()
  File "/usr/local/lib/python3.10/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/googleapiclient/http.py", line 923, in execute
    resp, content = _retry_request(
  File "/usr/local/lib/python3.10/site-packages/googleapiclient/http.py", line 191, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/oauth2client/transport.py", line 186, in new_request
    credentials._refresh(orig_request_method)
  File "/usr/local/lib/python3.10/site-packages/oauth2client/client.py", line 761, in _refresh
    self._do_refresh_request(http)
  File "/usr/local/lib/python3.10/site-packages/oauth2client/client.py", line 819, in _do_refresh_request
    raise HttpAccessTokenRefreshError(error_msg, status=resp.status)
oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Bad Request

include imperial units

Hi,
Apologies for being American, but afaict the sensors only output metric measurements where I'd want something at a glance to be imperial units. I'm not sure how easy or difficult this would be to implement (1.8m is more readable than 5.9ft), but I'm sure it would be appreciated by plenty of people.

Error: Error adding entities for domain sensor with platform google_fit / Error while setting up google_fit platform for sensor

Hi!
I tried to setup this integration, but it produces an error on startup and does not create the entities with my Google Fit data:

`Logger: homeassistant.components.sensor
Source: custom_components/google_fit/sensor.py:247
Integration: Sensor (documentation, issues)
First occurred: 13:35:23 (2 occurrences)
Last logged: 13:35:23

Error adding entities for domain sensor with platform google_fit
Error while setting up google_fit platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 383, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 588, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 666, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 419, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 460, in _async_write_ha_state
extra_state_attributes = self.device_state_attributes
File "/config/custom_components/google_fit/sensor.py", line 247, in device_state_attributes
return self._attributes
AttributeError: 'GoogleFitWeightSensor' object has no attribute '_attributes'`

Thanks for any help in advance!

AttributeError: 'NoneType' object has no attribute 'authorize'

I'm having this issue after copying the google_fit.token to config after finding the solution to the 'invalid scope' error this plugin shows after initial installation. Any ideas of how to resolve? It seems like this plugin and the many variants it's forked from just don't work. I'm familiar with YAML and some basic python, but I'm no regular coder so I'm not sure where to begin.

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/google_fit/sensor.py", line 176, in setup_platform client = _get_client(token_file) File "/config/custom_components/google_fit/sensor.py", line 98, in _get_client http = credentials.authorize(httplib2.Http()) AttributeError: 'NoneType' object has no attribute 'authorize'

No 'version' key in the manifest file for custom integration 'google_fit'.

Hi. Thanks for this integration, it's awesome.

Just a heads up, I'm seeing the following warning in the log:
2021-03-25 10:47:57 WARNING (MainThread) [homeassistant.loader] No 'version' key in the manifest file for custom integration 'google_fit'. This will not be allowed in a future version of Home Assistant. Please report this to the maintainer of 'google_fit'

Sensors disappeared

Everything was working well, but yesterday, the sensors all disappeared from HA. I have tried re-downloading the integration. It had been fine for a while.

Authentication code expired, please restart Home-Assistant and try again

HASS 2021.07.04

I got permanent the following Error:

Authentication code expired, please restart Home-Assistant and try again

2021-07-23 11:31:04 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform google_fit
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 383, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 588, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 666, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 419, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 460, in _async_write_ha_state
    extra_state_attributes = self.device_state_attributes
  File "/config/custom_components/google_fit/sensor.py", line 247, in device_state_attributes
    return self._attributes
AttributeError: 'GoogleFitWeightSensor' object has no attribute '_attributes'

Client ID and Client Secret is correct and working with the Google Calendar Integration.
Google Fitness API is also enabled.

Feature request: blood pressure

Can you extend the code with reading blood pressure from google fit? Im syncing data from Omron to google fit so that I can log it in HA.

There are also more measurements which may be interesting to add considering new smartwatches that can log blood oxygen.

Bug: getting the latest weight might not really get the latest weight

Hi,

I just observed a situation where not the latest weight is returned but the third but last point.

The latest 5 datapoints together with the relevant timestamps were (sorted from newest to older)

1. Entry
74.35
modifiedTimeMillis=1618809864359   # same timestamp as 2. and 3. Entry
startTimeNanos=1618805176000000000 # just a few secons newer than 2. Entry (was weighting two consecutive times)
endTimeNanos=1618805176000000000

2. Entry
74.35
modifiedTimeMillis=1618809864359   # same timestamp as 1. and 3. Entry
startTimeNanos=1618805151000000000 # just a few seconds older than 1. Entry
endTimeNanos=1618805151000000000

3. Entry
73.55
modifiedTimeMillis=1618809864359   # same timestamp as 2. and 3. Entry
startTimeNanos=1618766540000000000 # some hours older than 2. and 2. Entry
endTimeNanos=1618766540000000000

4. Entry
74.95
modifiedTimeMillis=1618733932941
startTimeNanos=1618733799000000000
endTimeNanos=1618733799000000000

5. Entry
75.1
modifiedTimeMillis=1618727511647
startTimeNanos=1618725662927000000
endTimeNanos=1618725662927000000

Apparently, the modifiedTimeMillis for the latest three data points (Entry 1, 2 and 3) are the same.
I suspect that this is due to the fact that the weight was updated from a Mi Scale 2 from the mi app to google fit.
I guess that the mi fit app only synchronizes the weights from time to time to google fit.
My guess is that the latest data points were synchronized from the mi app to google fit at the same time.

What happend now is that the google_fit integration's GoogleFitWeightSensor.update() read Entry 1, 2 and 3
in this order and as modifiedTimeMillis is used as key for storing the values, only the third entry was stored
in the dict (overwriting Entry 1 and 2 as their modifiedTimeMillis is the same)

Solution

Apparently the startTimeNanos and endTimeNanos are correct and different between these three latest entries.
Therefore, to solve the problem GoogleFitWeightSensor.update() should rather use either startTimeNanos or
endTimeNanos as key for storing the weight and later sorting.

somewhere around line 330 it should then

# OLD: last_update_milis = int(datapoint.get('modifiedTimeMillis', 0))
startTimeNanos = int(datapoint.get('startTimeNanos', 0))

I just confirmed that this works and yields then the correct latest entry.

Btw. I didn't check for other sensors but I believe that probably everywhere modifiedTimeMillis should be replace by startTimeNanos.

Error 400: invalid_request

After couple of days working the integration stopped providing data, log says:

google.auth.exceptions.RefreshError: ('invalid_grant: Token has been expired or revoked.', {'error': 'invalid_grant', 'error_description': 'Token has been expired or revoked.'})

while trying to re-authenticate with google, google says

You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy for keeping apps secure.

I am only one experiencing this?

Google Nest Hub Gen2 Sleep data

Hello I own a nets Hub Gen2 it has a sleep monitoring function and it uploads the data to google fit, but the problem is that it doesnโ€™t shop up in sleep sensor, so can you please fix this

Update Interval?

How often are the sensors updated?
Adjusting this to something like at least every few minutes would be helpful at least for the heart rate.

Heart rate sensor unknown

Sensor heart rate is unknown and sleep is 0
rest of the sensors are working.

Anyone knows where I can get log's to see where it is going wrong?

Error adding entities for domain sensor with platform google_fit && google_fit: Error on device update!

hi, can anybody help me to get the google_fit integration started?
here are my logs:

2023-09-14 12:36:33.765 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform google_fit
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1002, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 730, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 830, in _async_write_ha_state
state, attr = self._async_generate_attributes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 774, in _async_generate_attributes
attr.update(self.extra_state_attributes or {})
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/google_fit/sensor.py", line 249, in extra_state_attributes
return self._attributes
^^^^^^^^^^^^^^^^
AttributeError: 'GoogleFitWeightSensor' object has no attribute '_attributes'
2023-09-14 12:36:33.801 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 573, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 938, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/google_fit/sensor.py", line 430, in update
heartrate_datasources = self._get_datasources('com.google.heart_rate.bpm')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/google_fit/sensor.py", line 274, in _get_datasources
datasources_request = self._client.users().dataSources().list(
^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'users'

Second user

What would be the necessary steps for adding a second user? I am trying to add the corresponding account and api data of my wife, but currently it only shows the same sensor values for both of us.

Following the example i added two of these:

  • platform: google_fit
    name: Bob
    client_id: !secret google_fit_client_id
    client_secret: !secret google_fit_client_secret

There was no question in the notifications for the second account - is the problem that I opened my wifes account in a private tab for the api configuration?

2021.12.0b0: implements device_state_attributes warning

This is with home-assistant 2021.12.0.b0. I run it in docker.
The integration is setting-up just fine and pulling the data as expected but I get the following warnings:

2021-12-03 23:28:49 WARNING (MainThread) [homeassistant.helpers.entity] Entity sensor.google_fit_weight (<class 'custom_components.google_fit.sensor.GoogleFitWeightSensor'>) implements device_state_attributes. Please report it to the custom component author.

2021-12-03 23:28:49 WARNING (MainThread) [homeassistant.helpers.entity] Entity sensor.google_fit_heart_rate (<class 'custom_components.google_fit.sensor.GoogleFitHeartRateSensor'>) implements device_state_attributes. Please report it to the custom component author.

2021-12-03 23:28:49 WARNING (MainThread) [homeassistant.helpers.entity] Entity sensor.google_fit_height (<class 'custom_components.google_fit.sensor.GoogleFitHeightSensor'>) implements device_state_attributes. Please report it to the custom component author.

2021-12-03 23:28:49 WARNING (MainThread) [homeassistant.helpers.entity] Entity sensor.google_fit_steps (<class 'custom_components.google_fit.sensor.GoogleFitStepsSensor'>) implements device_state_attributes. Please report it to the custom component author.

2021-12-03 23:28:49 WARNING (MainThread) [homeassistant.helpers.entity] Entity sensor.google_fit_sleep (<class 'custom_components.google_fit.sensor.GoogleFitSleepSensor'>) implements device_state_attributes. Please report it to the custom component author.

2021-12-03 23:28:49 WARNING (MainThread) [homeassistant.helpers.entity] Entity sensor.google_fit_move_time (<class 'custom_components.google_fit.sensor.GoogleFitMoveTimeSensor'>) implements device_state_attributes. Please report it to the custom component author.

2021-12-03 23:28:49 WARNING (MainThread) [homeassistant.helpers.entity] Entity sensor.google_fit_calories (<class 'custom_components.google_fit.sensor.GoogleFitCaloriesSensor'>) implements device_state_attributes. Please report it to the custom component author.

2021-12-03 23:28:49 WARNING (MainThread) [homeassistant.helpers.entity] Entity sensor.google_fit_distance (<class 'custom_components.google_fit.sensor.GoogleFitDistanceSensor'>) implements device_state_attributes. Please report it to the custom component author.

Unable to make it work

Can't get it to work.
HASS logs :

home-assistant       | 2021-12-21 00:13:47 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform google_fit
home-assistant       | Traceback (most recent call last):
home-assistant       |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
home-assistant       |     await asyncio.gather(*tasks)
home-assistant       |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 613, in _async_add_entity
home-assistant       |     await entity.add_to_platform_finish()
home-assistant       |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in add_to_platform_finish
home-assistant       |     self.async_write_ha_state()
home-assistant       |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in async_write_ha_state
home-assistant       |     self._async_write_ha_state()
home-assistant       |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in _async_write_ha_state
home-assistant       |     self.device_state_attributes is not None
home-assistant       |   File "/config/custom_components/google_fit/sensor.py", line 247, in device_state_attributes
home-assistant       |     return self._attributes
home-assistant       | AttributeError: 'GoogleFitWeightSensor' object has no attribute '_attributes'
home-assistant       | 2021-12-21 00:13:47 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
home-assistant       | Traceback (most recent call last):
home-assistant       |   File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
home-assistant       |     await entity.async_device_update(warning=False)
home-assistant       |   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 684, in async_device_update
home-assistant       |     await task
home-assistant       |   File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
home-assistant       |     result = self.fn(*self.args, **self.kwargs)
home-assistant       |   File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 195, in wrapper
home-assistant       |     result = method(*args, **kwargs)
home-assistant       |   File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 195, in wrapper
home-assistant       |     result = method(*args, **kwargs)
home-assistant       |   File "/config/custom_components/google_fit/sensor.py", line 428, in update
home-assistant       |     heartrate_datasources = self._get_datasources('com.google.heart_rate.bpm')
home-assistant       |   File "/config/custom_components/google_fit/sensor.py", line 272, in _get_datasources
home-assistant       |     datasources_request = self._client.users().dataSources().list(
home-assistant       | AttributeError: 'NoneType' object has no attribute 'users'
...
![image](https://user-images.githubusercontent.com/860357/146839922-e3d2a207-abbc-4caa-b761-2cb358fa46dc.png)

Credentials seems to be correct.
![image](https://user-images.githubusercontent.com/860357/146840539-caf2b496-ee01-48a1-a10b-61543fc98521.png)
What am I doing wrong ? 

Instructions not working - Sensor key not provided

Note - I'm quite new at HA development. I think it's a super easy
When I set up the Google Fit component using the steps in the configuration (sensor.yaml).
I didn't copy my secrets to a separate file to first test. I copied the extact snippet provided in the documentation:
image

However, when I check my configuration.yaml it says there is a required key missing:
image

Probably it's a typo, but with no other way to contact you - what key am I missing?

Error 401

I tried removing it, and following the steps again. But still the same results
I tried setting my time to "(GMT+00:00) GMT (no daylight saving)" but that also doesn't work
I checked the account, and I can see data in my Google fit myself though the app with the same account.
image

debug logs:

2023-04-26 08:51:22.643 WARNING (SyncWorker_4) [homeassistant.loader] We found a custom integration google_fit which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
...
2023-04-26 08:51:34.670 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.google_fit
...
2023-04-26 08:51:37.477 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform google_fit
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 455, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 823, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 568, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 635, in _async_write_ha_state
attr.update(self.extra_state_attributes or {})
File "/config/custom_components/google_fit/sensor.py", line 249, in extra_state_attributes
return self._attributes
AttributeError: 'GoogleFitWeightSensor' object has no attribute '_attributes'
2023-04-26 08:51:37.543 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 521, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in async_device_update
await task
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/google_fit/sensor.py", line 430, in update
heartrate_datasources = self._get_datasources('com.google.heart_rate.bpm')
File "/config/custom_components/google_fit/sensor.py", line 274, in _get_datasources
datasources_request = self._client.users().dataSources().list(
AttributeError: 'NoneType' object has no attribute 'users'
2023-04-26 08:51:37.550 INFO (MainThread) [homeassistant.setup] Setup of domain zone took 2.8 seconds
2023-04-26 08:51:37.555 INFO (MainThread) [homeassistant.setup] Setup of domain input_text took 2.7 seconds
2023-04-26 08:51:37.559 INFO (MainThread) [homeassistant.setup] Setup of domain application_credentials took 1.2 seconds
2023-04-26 08:51:37.568 INFO (MainThread) [homeassistant.setup] Setup of domain schedule took 1.8 seconds
2023-04-26 08:51:37.579 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up google_fit platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 312, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 455, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 823, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 568, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 635, in _async_write_ha_state
attr.update(self.extra_state_attributes or {})
File "/config/custom_components/google_fit/sensor.py", line 249, in extra_state_attributes
return self._attributes
AttributeError: 'GoogleFitWeightSensor' object has no attribute '_attributes'
2023-04-26 08:51:37.585 INFO (MainThread) [homeassistant.setup] Setup of domain scene took 2.8 seconds
2023-04-26 08:51:37.749 INFO (MainThread) [homeassistant.setup] Setting up hacs
2023-04-26 08:51:37.750 INFO (MainThread) [homeassistant.setup] Setup of domain hacs took 0.0 seconds
2023-04-26 08:51:38.066 INFO (MainThread) [homeassistant.setup] Setting up goodwe
2023-04-26 08:51:38.067 INFO (MainThread) [homeassistant.setup] Setup of domain goodwe took 0.0 seconds
2023-04-26 08:51:38.095 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 521, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in async_device_update
await task
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/google_fit/sensor.py", line 369, in update
height_datasources = self._get_datasources('com.google.height')
File "/config/custom_components/google_fit/sensor.py", line 274, in _get_datasources
datasources_request = self._client.users().dataSources().list(
AttributeError: 'NoneType' object has no attribute 'users'
2023-04-26 08:51:38.100 INFO (MainThread) [custom_components.hacs]
...
2023-04-26 08:51:38.151 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
...
File "/config/custom_components/google_fit/sensor.py", line 490, in update
for point in self._get_dataset(self.DATA_SOURCE)["point"]:
File "/config/custom_components/google_fit/sensor.py", line 284, in _get_dataset
return self._client.users().dataSources(). \
AttributeError: 'NoneType' object has no attribute 'users'
2023-04-26 08:51:38.163 DEBUG (SyncWorker_5) [custom_components.google_fit.sensor] Starttime 2023-04-25T17:00:00Z, Endtime 2023-04-26T11:00:00Z
2023-04-26 08:51:38.164 INFO (MainThread) [homeassistant.setup] Setting up stream
2023-04-26 08:51:38.309 INFO (MainThread) [homeassistant.setup] Setup of domain stream took 0.1 seconds
2023-04-26 08:51:38.312 INFO (MainThread) [homeassistant.setup] Setting up button
2023-04-26 08:51:38.315 INFO (MainThread) [homeassistant.setup] Setup of domain button took 0.0 seconds
2023-04-26 08:51:38.321 INFO (MainThread) [homeassistant.setup] Setting up presence_simulation
2023-04-26 08:51:38.321 INFO (MainThread) [homeassistant.setup] Setup of domain presence_simulation took 0.0 seconds
2023-04-26 08:51:38.342 INFO (MainThread) [homeassistant.setup] Setup of domain input_boolean took 3.5 seconds
2023-04-26 08:51:38.348 INFO (MainThread) [homeassistant.setup] Setup of domain input_number took 3.5 seconds
2023-04-26 08:51:38.350 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 521, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in async_device_update
await task
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/google_fit/sensor.py", line 628, 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'
2023-04-26 08:51:38.421 INFO (SyncWorker_4) [homeassistant.loader] Loaded google_translate from homeassistant.components.google_translate
2023-04-26 08:51:38.429 INFO (MainThread) [homeassistant.setup] Setting up co2signal
2023-04-26 08:51:38.430 INFO (MainThread) [homeassistant.setup] Setup of domain co2signal took 0.0 seconds
2023-04-26 08:51:38.446 INFO (MainThread) [homeassistant.setup] Setup of domain input_datetime took 2.6 seconds
2023-04-26 08:51:38.449 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 521, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in async_device_update
await task
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/google_fit/sensor.py", line 524, in update
for point in self._get_dataset(self.DATA_SOURCE)["point"]:
File "/config/custom_components/google_fit/sensor.py", line 284, in _get_dataset
return self._client.users().dataSources(). \
AttributeError: 'NoneType' object has no attribute 'users'
2023-04-26 08:51:38.465 INFO (MainThread) [homeassistant.setup] Setting up buienradar
2023-04-26 08:51:38.466 INFO (MainThread) [homeassistant.setup] Setup of domain buienradar took 0.0 seconds
2023-04-26 08:51:38.480 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.energy
2023-04-26 08:51:38.488 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 521, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in async_device_update
await task
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/google_fit/sensor.py", line 557, in update
for point in self._get_dataset(self.DATA_SOURCE)["point"]:
File "/config/custom_components/google_fit/sensor.py", line 284, in _get_dataset
return self._client.users().dataSources(). \
AttributeError: 'NoneType' object has no attribute 'users'
2023-04-26 08:51:38.523 INFO (MainThread) [homeassistant.setup] Setting up camera
2023-04-26 08:51:38.537 INFO (MainThread) [homeassistant.setup] Setup of domain camera took 0.0 seconds
2023-04-26 08:51:38.543 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 521, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in async_device_update
await task
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 190, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/google_fit/sensor.py", line 590, in update
for point in self._get_dataset(self.DATA_SOURCE)["point"]:
File "/config/custom_components/google_fit/sensor.py", line 284, in _get_dataset
return self._client.users().dataSources(). \
AttributeError: 'NoneType' object has no attribute 'users'

Problems defining the configuratin

Hi I was trying to connect my fit api to this sensor. But there seems to be some problems with the plugin since it seems to not recognise the parameter "client_id" inside the configuration.

This is the error:

image

And this is the config file:

image

at this moment it is commented since it i snot working.

'invalid_client' on restart

I already have a couple of other Google integrations (Calendar and TTS). I added the Fitness API to my Home Assistant project on the Cloud Console. When I restart Home Assistant this is the error I get in notifications.

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

Any way to update data on Google Fit?

For example I have a weighing scale that is connected to Home Assistant, but cannot directly update my weigh on Google Fit. Is there any way to update my weight to Google Fit with this addon (instead of just pulling data from Google Fit).

Sleep sensor: Session limit of 10000 exceeded.

I noticed this in my logs:

2021-03-29 08:30:54 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.sleep fails
Traceback (most recent call last):
  File "/srv/hass/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 277, in async_update_ha_state
    await self.async_device_update()
  File "/srv/hass/lib/python3.8/site-packages/homeassistant/helpers/entity.py", line 473, in async_device_update
    raise exc
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/hass/lib/python3.8/site-packages/homeassistant/util/__init__.py", line 285, in wrapper
    result = method(*args, **kwargs)
  File "/srv/hass/lib/python3.8/site-packages/homeassistant/util/__init__.py", line 285, in wrapper
    result = method(*args, **kwargs)
  File "/home/hass/.homeassistant/custom_components/google_fit/sensor.py", line 626, in update
    sleep_dataset =  self._client.users().sessions().list(userId='me',fields='session',startTime=starttime,endTime=endtime).execute()
  File "/srv/hass/lib/python3.8/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/srv/hass/lib/python3.8/site-packages/googleapiclient/http.py", line 842, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://fitness.googleapis.com/fitness/v1/users/me/sessions?fields=session&startTime=2021-03-28T17%3A00%3A00Z&endTime=2021-03-29T11%3A00%3A00Z&alt=json returned "Session limit of 10000 exceeded.">

Stop Working

Logger: homeassistant.components.sensor
Source: custom_components/google_fit/sensor.py:98
Integration: Sensor (documentation, issues)
First occurred: 20:47:52 (1 occurrences)
Last logged: 20:47:52

Error while setting up google_fit platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 293, in _async_setup_platform
await asyncio.shield(task)
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/google_fit/sensor.py", line 176, in setup_platform
client = _get_client(token_file)
File "/config/custom_components/google_fit/sensor.py", line 98, in _get_client
http = credentials.authorize(httplib2.Http())
AttributeError: 'NoneType' object has no attribute 'authorize'

Heart Sensor / Sleep Sensor

Hello @cyberjunky and friends...

First I would like to say thanks for this amazing work....

Now I will say my problem... actually I am trying do this both sensors work in my home asssistant, but I really not know more what I should to do... I have date from others sensors, less Heart and Sleep...
Could you help me?

Thank you, any suggest will be welcome!

ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:2578)

Seeing this after updating HASS to 2023.5.x when starting up.

2023-05-05 11:42:29.748 ERROR (MainThread) [homeassistant.components.sensor] google_fit: Error on device update!
Traceback (most recent call last):
  File "/srv/hass/lib/python3.10/site-packages/homeassistant/helpers/entity_platform.py", line 521, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/srv/hass/lib/python3.10/site-packages/homeassistant/helpers/entity.py", line 784, in async_device_update
    await coro
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/hass/lib/python3.10/site-packages/homeassistant/util/__init__.py", line 190, in wrapper
    result = method(*args, **kwargs)
  File "/srv/hass/lib/python3.10/site-packages/homeassistant/util/__init__.py", line 190, in wrapper
    result = method(*args, **kwargs)
  File "/home/hass/.homeassistant/custom_components/google_fit/sensor.py", line 321, in update
    weight_data = weight_request.execute()
  File "/srv/hass/lib/python3.10/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/srv/hass/lib/python3.10/site-packages/googleapiclient/http.py", line 923, in execute
    resp, content = _retry_request(
  File "/srv/hass/lib/python3.10/site-packages/googleapiclient/http.py", line 222, in _retry_request
    raise exception
  File "/srv/hass/lib/python3.10/site-packages/googleapiclient/http.py", line 191, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "/srv/hass/lib/python3.10/site-packages/oauth2client/transport.py", line 173, in new_request
    resp, content = request(orig_request_method, uri, method, body,
  File "/srv/hass/lib/python3.10/site-packages/oauth2client/transport.py", line 280, in request
    return http_callable(uri, method=method, body=body, headers=headers,
  File "/srv/hass/lib/python3.10/site-packages/httplib2/__init__.py", line 1701, in request
    (response, content) = self._request(
  File "/srv/hass/lib/python3.10/site-packages/httplib2/__init__.py", line 1421, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/srv/hass/lib/python3.10/site-packages/httplib2/__init__.py", line 1373, in _conn_request
    response = conn.getresponse()
  File "/usr/lib/python3.10/http/client.py", line 1375, in getresponse
    response.begin()
  File "/usr/lib/python3.10/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.10/http/client.py", line 279, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.10/socket.py", line 705, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.10/ssl.py", line 1274, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.10/ssl.py", line 1130, in read
    return self._sslobj.read(len, buffer)
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:2578)

Oddly, while some sensors work just fine (e.g. steps, move time) the one for distance is not.

Error 401: client_id and client_secret could not be retrieved

I tried installing the Google Fit integration using the same client_id and client secret as my Google Calendar integration.
This gave the error code 400: config flow could not be found.
Afterwards, I used the same client_id and client_secret as my Google Nest integration.
This gave the error code 401: client_id and client_secret could not be retrieved.

Both credentials are correct and currently in use for the corresponding integration.
I am running HA Core 2023.1.6 .

If you need any further information, please let me know.

Kind regards,

Robin

advise on error required

i was using your integration from about a year ago - because hacs lost the custom directory i think
i re-added the integration and this updated it and has broken
please advise on how to fix

2021-04-29 00:56:21 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform google_fit
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 364, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 558, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 581, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 334, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 375, in _async_write_ha_state
    extra_state_attributes = self.device_state_attributes
  File "/config/custom_components/google_fit/sensor.py", line 247, in device_state_attributes
    return self._attributes
AttributeError: 'GoogleFitWeightSensor' object has no attribute '_attributes'
2021-04-29 00:56:21 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy google_maps
2021-04-29 00:56:21 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 407, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 516, 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 280, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 280, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/google_fit/sensor.py", line 428, in update
    heartrate_datasources = self._get_datasources('com.google.heart_rate.bpm')
  File "/config/custom_components/google_fit/sensor.py", line 272, in _get_datasources
    datasources_request = self._client.users().dataSources().list(
AttributeError: 'NoneType' object has no attribute 'users'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.