Maybe I am too impatient as always but after declaring the Fit app as “production” (no verification was needed) in Google it has been working for 10 days after last token generation via Python script… vs 7 days before Fingers crossed!
Reads all our family Google Fit data via MiBand and MiScale2 and displays nicely in HA
Best, JR
I’m getting the following error:
2021-09-30 15:25:16 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform google_fit
Traceback (most recent call last):
File "C:\Python38\lib\site-packages\homeassistant\helpers\entity_platform.py", line 382, in async_add_entities
await asyncio.gather(*tasks)
File "C:\Python38\lib\site-packages\homeassistant\helpers\entity_platform.py", line 587, in _async_add_entity
await entity.add_to_platform_finish()
File "C:\Python38\lib\site-packages\homeassistant\helpers\entity.py", line 698, in add_to_platform_finish
self.async_write_ha_state()
File "C:\Python38\lib\site-packages\homeassistant\helpers\entity.py", line 464, in async_write_ha_state
self._async_write_ha_state()
File "C:\Python38\lib\site-packages\homeassistant\helpers\entity.py", line 505, in _async_write_ha_state
extra_state_attributes = self.device_state_attributes
File "C:\Users\stefa\AppData\Roaming\.homeassistant\custom_components\google_fit\sensor.py", line 247, in device_state_attributes
return self._attributes
AttributeError: 'GoogleFitWeightSensor' object has no attribute '_attributes'
I already tried to remove token files and py cache…
When I restart HA, I also get as soon as I restart the following notification: Authentication code expired, please restart Home-Assistant and try again
Same here for me!
Now I am able to get the sensors showing up. Only height and weight data are being provided. All other sensors show this in the Configuration Log: oauth2client.client.HttpAccessTokenRefreshError: unauthorized_client: Unauthorized
Not sure how to resolve this…
Made progress - no errors now. However, sensors are not updating. From the HA Configuration Log:
DEBUG (SyncWorker_12) [custom_components.google_fit.sensor] Last weight 180.0
DEBUG (SyncWorker_0) [custom_components.google_fit.sensor] Last weight 70.0
DEBUG (SyncWorker_1) [custom_components.google_fit.sensor] Last height 183.00
DEBUG (SyncWorker_8) [custom_components.google_fit.sensor] Steps 0
DEBUG (SyncWorker_13) [custom_components.google_fit.sensor] Starttime 2021-11-26T17:00:00Z, Endtime 2021-11-27T11:00:00Z
DEBUG (SyncWorker_13) [custom_components.google_fit.sensor] Sleep dataset {‘session’: []}
DEBUG (SyncWorker_9) [custom_components.google_fit.sensor] Starttime 2021-11-26T17:00:00Z, Endtime 2021-11-27T11:00:00Z
DEBUG (SyncWorker_9) [custom_components.google_fit.sensor] Meditation dataset {‘session’: []}
DEBUG (SyncWorker_2) [custom_components.google_fit.sensor] Move time 0
DEBUG (SyncWorker_16) [custom_components.google_fit.sensor] Calories 0
DEBUG (SyncWorker_14) [custom_components.google_fit.sensor] Distance 0.0
DEBUG (SyncWorker_3) [custom_components.google_fit.sensor] Distance 0.0
Hi!
I also have problem - sensors updated only when HA restart. (( Is it possible to start updating by automation? May be reload only Google fit integration, not whole HA?
Regards
Anybody else having issues with this and 2021.12.x release?
The entities are created but I get errors in the logs saying that the attributes can’t be created
I Get the following error
Error: invalid_scope
I get this notification:
“Authentication code expired, please restart Home-Assistant and try again”
but I have no clue how to resolve it. Restarting does not work. Anybody any clue?
Im doing another try at getting fit to work.
I installed the integration via HACS (multiple times/versions at this point - trying for months each other weekend)
After rebooting hass im getting notification:
Google Fit Setup
Error: Invalid response 400. Error: invalid_scope
You will need to restart hass after fixing.
But never any login code message as I get with google calendar for example
No .token
files are created in config folder.
And in logs I have this error message:
Logger: homeassistant.components.sensor
Source: custom_components/google_fit/sensor.py:293
Integration: Sensor (documentation, issues)
First occurred: 11:04:27 (1 occurrences)
Last logged: 11:04:27
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 735, 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 460, in update
height_datasources = self._get_datasources('com.google.height')
File "/config/custom_components/google_fit/sensor.py", line 293, in _get_datasources
datasources_request = self._client.users().dataSources().list(
AttributeError: 'NoneType' object has no attribute 'users'
Tried removing pycache, reinstalling, creating the token file by hand based on OAuth Playground - totally out of ideas.
Last tried with:
39c047f
vmanuel
Google Fit Sensor
This fixed it for me - Authentication code expired, please restart Home-Assistant and try again · Issue #12 · cyberjunky/home-assistant-google_fit · GitHub
I’m guessing you abandoned this? I was trying to post an issue and they’re disabled… so I’m guessing it is completely broken? What I tried to post in case.
“Well, I can’t seem to get your version running. The other version I’m running just fine, but being in the country I am in, I was unfortunately taught imperial, I try using yours as standalone and it gets mad and tells me the integration doesn’t exist every time I attempt to input my credentials in Configs.
I was able to get it to stop doing this by using your and someone else’s at the same time, but in honesty I think it just overrides yours because they’re still imperial measurements.”
Something completely wrong with authorization.
Old token file gives 401 error.
New file can’t be created, because authorization procedure doesn’t start.
Standalone authorisation python script from this thread doesn’t accept the code returned by Google.
Looks like oath2 procedure has changed again or something
Did some investigation about the problem.
Old token files was made with oath2 credential type “Desktop”. Home Assistant gives 401. Error: invalid_client error for this type of tokens now. New tokens of this type could be obtained, but can’t be used with Home Assistant.
Due to installation manual on this git you should make oath2 credential with type “TV and Limited Input”. This credentials can’t be obtained due to new Google security policy. Add-on gives 400: invalid_request error with “redirect_uri: urn:ietf:wg:oauth:2.0:oob” message.
Could author repair authentication procedure of the component, please?
@astronaut63 did you generate new token lately using your standalone procedure? I’ve got Error 400: invalid_request when I’ve paste the generated link to obtain code. More info says that it does not comply with Google’s OAuth 2.0 policy related to application protection.
Hello, sorry, I try to find in the post how you were able to generate the _Google fit_google_fit.token = can you please tell me where is the routine?
I thank you in advance for your help.
The script runs standalone e.g. in a python environment or if you look at an older post there is a link to a command line. If you look back to post 172 from me in this thread (back inJune 21) I have posted the script and a few posts later I explain why I couldn’t get see a way to integrate it to run automatically within HA
I ran the script 11 days s ago and it works as expected - it asks me which google account I want to use, it then warns me that the app is not yet verified by Google and then when I proceed I get promoted to tick the 10 different data types I am giving access to. This then created the new token file which I copied to Home Assistant (and restarted HA)
Just tried again and the routine to create the token it is still working
Also Home Assistant still showing approx 11 Google data items (steps, Heart rate, Sleep time , distance …) all with live data
Ok, thanks for information. Then perhaps the problem is in my googlefit app on google developers site. I’ll check there.
Hello @astronaut63 ,
Thank you for your answer.
I must admit that I don’t understand exactly the process
I have succeeded to generate the CLIENT_ID, the CLIENT_SECRET and the TOKEN_FILE.
Unfortunatly, when I make putty on my raspberry and try to execute the python3 routine, here is the error which appears
Can you help me to understand what is going wrong in my process ?