Giter Club home page Giter Club logo

Comments (17)

jovandeginste avatar jovandeginste commented on August 16, 2024

ping @managementboy

from bs440.

keptenkurk avatar keptenkurk commented on August 16, 2024

actually just had it working once, but i remember that the authentication process was quite a pain...

from bs440.

jovandeginste avatar jovandeginste commented on August 16, 2024

Yes I can update the wiki to get to the point of getting the json, but since I didn't get the final part working so maybe I shouldn't touch the wiki just yet ;-)

from bs440.

thomashommel avatar thomashommel commented on August 16, 2024

I'm stuck at the last part, I have generated the json file (google.json) and it's copied to the BS440 folder on my pi. But what do I do then?

I don't understand this part: Copy and rename this file to the BS440 directory on the Pi and refer to this file in BS440.ini in the user section for the user this account belongs to.

Can you please help? @jovandeginste @keptenkurk @managementboy

from bs440.

keptenkurk avatar keptenkurk commented on August 16, 2024

Thomas,
The issue is that this plugin was never rewritten into the Plugin structure,
At some point i decided to create a structure where 3rd party plugins could be added wiithout the need to change the basic communication structure. Plugins process the received data into CSV, Domoticz, Email etc just to name a few...
The google integration was never converted into this new structure so it will not work anymore.
I started to fix this (as i'm a Gioogle Fit user now) so i hope nothing dramatically has changed over the years in accessing Google Fit by an application...
Stay tuned and hope for lots of rain (and little spouse priority requests)

from bs440.

thomashommel avatar thomashommel commented on August 16, 2024

Perfect!

I indeed spotted that one and added an BS440google.ini file and added "class Plugin" in the BS440google.py file, which made it load the plugin, but at the plugin execute phase the code would throw me an error and since I'm not a developer, that is where I got stuck :)

Would love to have this integration! Keep up the good work!

from bs440.

keptenkurk avatar keptenkurk commented on August 16, 2024

Ok, here you go! Just pushed the updates into master. Tested by using BS440test.py and seems to be working fine. Also see updated Wiki pages on this plugin.

from bs440.

keptenkurk avatar keptenkurk commented on August 16, 2024

Hmmm. Here the plugin causes the complete script to terminate silently after loading... (whereas BS440test loads it exactly the same way)... need to investigate! errr... silently, when loaded as service that is... (still early in the morning). Ok, needed to reinstall yaml en Oauth modules for some odd reason.

from bs440.

thomashommel avatar thomashommel commented on August 16, 2024

Thanks for your work! I indeed get a step further now, but when testing I get an error just after the PATCH command:

Thu, 24 Oct 2019 09:31:49 INFO GetGoogleClient Google client created
Thu, 24 Oct 2019 09:31:49 INFO AddGoogle Created a new dataset: xxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxx
Thu, 24 Oct 2019 09:31:49 INFO method URL being requested: GET https://www.googleapis.com/fitness/v1/users/me/dataSources/raw%XXcom.google.weight%XXXXXXXXXXXXXX%XXunknown%XXunknown%XX10000001?alt=json
Thu, 24 Oct 2019 09:31:49 INFO new_request Refreshing due to a 401 (attempt 1/2)
Thu, 24 Oct 2019 09:31:49 INFO _do_refresh_request Refreshing access_token
Thu, 24 Oct 2019 09:31:50 INFO AddGoogle Data Source ID: raw:com.google.weight:xxxxxxxxxxxx:unknown:unknown:10000001
Thu, 24 Oct 2019 09:31:50 INFO method URL being requested: PATCH https://www.googleapis.com/fitness/v1/users/me/dataSources/raw%XXcom.google.weight%XXXXXXXXXXXXXX%XXunknown%XXunknown%XX10000001/datasets/xxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxx?alt=json
Thu, 24 Oct 2019 09:31:50 ERROR execute Unable to update Google Fit: Error sending data.

Looks like the URL it generates with my data is not correct? I have redacted some of the info with x and X.

from bs440.

keptenkurk avatar keptenkurk commented on August 16, 2024

Could you test the same with the try: and except: removed? The try/except will catch any exceptions and only logs the final Error message. see at the bottom of https://github.com/keptenkurk/BS440/wiki/Plugin:-BS440google---Store-weight-in-Google-Fit
... and the interesting part is now on the console (not in the log) and only when BS440.py is run from commandline instead of started as service..

from bs440.

thomashommel avatar thomashommel commented on August 16, 2024

This is the error I get back:

Traceback (most recent call last):
File "BS440.py", line 318, in
plugin.execute(config, persondata, weightdatasorted, bodydatasorted)
File "plugins/BS440google.py", line 161, in execute
self.AddGoogle(self.googleClient, weightdata[0]['weight'], WEIGHTD, googleauthfile)
File "plugins/BS440google.py", line 117, in AddGoogle
value=[dict(fpVal=value)],), ],
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/http.py", line 856, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/fitness/v1/users/me/dataSources/raw%3Acom.google.weight%3A"MYNUMBERS"%3Aunknown%3Aunknown%3A10000001/datasets/"DATASETPART1"-"DATASETPART2"?alt=json returned "Unable to fetch DataSource for Dataset: raw:com.google.weight:"MYNUMBERS":unknown:unknown:10000001">

The "MYNUMBERS" part is the same and a set of numbers, but on the requested URL it is preceded by 3A, which seems like it doesn't belong there.

Thank you for your help so far!

from bs440.

keptenkurk avatar keptenkurk commented on August 16, 2024

Not sure what's going on here. Some difference comparing your responses with mine:
The 401 error (authentication error) in: Thu, 24 Oct 2019 09:31:49 INFO new_request Refreshing due to a 401 (attempt 1/2).
The %3A is not the problem. It is just the Hex presentation of the colon (:)

Are you sure creating the authentication file worked ok? Does your application show in the Google Fit app under Settings | Connected Apps (BS440 is listed in mine) and shows to have read/write access.

from bs440.

keptenkurk avatar keptenkurk commented on August 16, 2024

I discovered a bit of a design issue. Not all users in my household have a Google Fit account but the use of this plugin is defined globally when the application starts. Must think of a way to disable the use of a plugin for one/some of the users within the plugin .ini

from bs440.

keptenkurk avatar keptenkurk commented on August 16, 2024

Pushed an update taking care of the issue mentioned above.
...and a fix for a typo

from bs440.

thomashommel avatar thomashommel commented on August 16, 2024

Thank you so much for your help. I still receive the following error:

Sun, 27 Oct 2019 20:56:31 INFO GetGoogleClient Google client created
Sun, 27 Oct 2019 20:56:31 INFO AddGoogle Created a new dataset: "DATASET NUMBERS"
Sun, 27 Oct 2019 20:56:31 INFO method URL being requested: GET https://www.googleapis.com/fitness/v1/users/me/dataSources/raw%3Acom.google.weight%3A"DATASOURCE NUMBERS"%3AMedisana%3ABS430%3A10000001?alt=json
Sun, 27 Oct 2019 20:56:32 INFO AddGoogle Data Source ID: raw:com.google.weight:"DATASOURCE NUMBERS":Medisana:BS430:10000001
Sun, 27 Oct 2019 20:56:32 INFO method URL being requested: PATCH https://www.googleapis.com/fitness/v1/users/me/dataSources/raw%3Acom.google.weight%3A"DATASOURCE NUMBERS"%3AMedisana%3ABS430%3A10000001/datasets/"DATASET NUMBERS"?alt=json
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/fitness/v1/users/me/dataSources/raw%3Acom.google.weight%3A"DATASOURCE NUMBERS"%3AMedisana%3ABS430%3A10000001/datasets/"DATASET NUMBERS"?alt=json returned "Unable to fetch DataSource for Dataset: raw:com.google.weight:"DATASOURCE NUMBERS":Medisana:BS430:10000001">

It seems like the dataset is not being created correctly? Although the log says AddGoogle did create it. I tried to check if I could find the dataset with the google API explorer. This is the error if I test Users.dataSources.datasets: patch:

{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "DataSourceId in request: raw:com.google.weight:"DATASOURCE NUMBERS":Medisana:BS430:10000001 does not match DataSourceId in Dataset. "
}
],
"code": 400,
"message": "DataSourceId in request: raw:com.google.weight:"DATASOURCE NUMBERS":Medisana:BS430:10000001 does not match DataSourceId in Dataset. "
}
}

from bs440.

thomashommel avatar thomashommel commented on August 16, 2024

Intersting, if I try the Users.dataSources.datasets: get on the Google API explorer I do get the confirmation it exists, although it is empty:

{
"minStartTimeNs": "NUMBERS",
"maxEndTimeNs": "NUMBERS",
"dataSourceId": "raw:com.google.weight:"DATASOURCE NUMBERS":Medisana:BS430:10000001",
"point": []
}

from bs440.

keptenkurk avatar keptenkurk commented on August 16, 2024

Seems nothing going on anymore.

from bs440.

Related Issues (20)

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.