cyberjunky / home-assistant-google_fit

:hearts: This component tracks your Google Fit activities.
MIT License
99 stars 20 forks source link

Heart Sensor / Sleep Sensor #24

Open freitas666 opened 2 years ago

freitas666 commented 2 years ago

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!

martinrevert commented 2 years ago

+1

freitas666 commented 2 years ago

Looks like this repo not have any more updates...

cyberjunky commented 2 years ago

I cannot help with this easily since I do not have sleep or heart sensors myself connected to Google Fit. Which kind of sensors/data input do you have? Google Watch? Something else?

freitas666 commented 2 years ago

Hello @cyberjunky actually i got this sensors:

CEA09EB7-E354-4450-B8CA-4AA0015E3F35

cyberjunky commented 2 years ago

I mean physical sensors on your phone, watch, whatever to get data in the HA sensors.. Do you see your heartrate in the Google Fit app?

freitas666 commented 2 years ago

Yes in the apps including google fit i see my heartrate and sleep time!

cyberjunky commented 2 years ago

With which physical sensors do you measure them?

ShurikenGitHub commented 2 years ago

I use the "Sleep as android" app to measure sleep in google fit, very easy, no extra hardware required. The sleep is also unknown for me with the integration, but in the google fit app it is available.

freitas666 commented 2 years ago

I use the "Sleep as android" app to measure sleep in google fit, very easy, no extra hardware required.

The sleep is also unknown for me with the integration, but in the google fit app it is available.

My smartwatch send the information correct to google fit.. I dont have problems with "google fit" date... But with integration with Home Assistant using hacs google fit addon..

martinrevert commented 2 years ago

@cyberjunky Hi Ron, i believe it has to do with the scopes.

Heart Rate and Sleep need separate scopes for security reasons. Google considers reading that data is "Restricted".

scopes

Sorry that I don't have a proper HASS dev environment to test it and send you a pull request, but your Google authorization scopes looks like this:

SCOPES = ['https://www.googleapis.com/auth/fitness.body.read', 'https://www.googleapis.com/auth/fitness.body.write', 'https://www.googleapis.com/auth/fitness.activity.read', 'https://www.googleapis.com/auth/fitness.location.read']

I think that adding the proper scopes this will work for me and the rest of the guys:

SCOPES = ['https://www.googleapis.com/auth/fitness.body.read', 'https://www.googleapis.com/auth/fitness.body.write', 'https://www.googleapis.com/auth/fitness.activity.read', 'https://www.googleapis.com/auth/fitness.location.read', 'https://www.googleapis.com/auth/fitness.sleep.read', 'https://www.googleapis.com/auth/fitness.heart_rate.read', ]

Also, I'm not so sure the "fitness.body.write" scope is needed for this plugin that is just a read info addon.

Don't bother if you can't test it yourself, we can do it for you and report.

Thanks!

freitas666 commented 2 years ago

Hello,

This new scopes work?

If you want i can test :)

Enviado do meu iPhone

Em 3 de jun. de 2022, à(s) 12:27, Martin Revert @.***> escreveu:



@cyberjunkyhttps://github.com/cyberjunky Hi Ron, i believe it has to do with the scopes.

Heart Rate and Sleep need separate scopes for security reasons. Google considers reading that data as "Restricted".

scopeshttps://developers.google.com/fit/datatypes#authorization_scopes

Sorry that I don't have a proper HASS dev environmet to test it and send you a pull request, but your Google authorization scopes looks like this:

SCOPES = ['https://www.googleapis.com/auth/fitness.body.read', 'https://www.googleapis.com/auth/fitness.body.write', 'https://www.googleapis.com/auth/fitness.activity.read', 'https://www.googleapis.com/auth/fitness.location.read']

I think that adding the proper scopes this will work for me and the rest of the guys:

SCOPES = ['https://www.googleapis.com/auth/fitness.body.read', 'https://www.googleapis.com/auth/fitness.body.write', 'https://www.googleapis.com/auth/fitness.activity.read', 'https://www.googleapis.com/auth/fitness.location.read', 'https://www.googleapis.com/auth/fitness.sleep.read', 'https://www.googleapis.com/auth/fitness.heart_rate.read', ]

Also, I'm not so sure the "fitness.body.write" scope is needed for this plugin that is just a read info addon.

Don't bother if you can't test it yourself, we can do it for you and report.

Thanks!

— Reply to this email directly, view it on GitHubhttps://github.com/cyberjunky/home-assistant-google_fit/issues/24#issuecomment-1146075822, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAQ7DLRIJHZXQMYMO5NIMKLVNIP4VANCNFSM5V3KJRMQ. You are receiving this because you authored the thread.Message ID: @.***>

martinrevert commented 2 years ago

Hello, This new scopes work? If you want i can test :)

I believe they must work, my guess is based on the fact that I've been hit by the same issue over an Android app I've been developing. So probably, we can give it a try. If @cyberjunky push a new version, we can commit to bring back the results here.

cyberjunky commented 2 years ago

Can you try version 1.0.7? I added the scopes and it kept working, i have no heart/sleep data to test with.

ScottG489 commented 2 years ago

FYI, via the Fit app you can measure your heart rate using your phones camera. I just tried it after updating to the latest version of this integration and it's still showing as "Unknown". Perhaps not enough time has passed yet.

lichenophile commented 2 years ago

I have tried 1.0.7 both with data synced to gfit and with a manual entry in gfit itself, HA still reporting 'unknown'.

Interestingly, I don't have an option for camera HR in gfit, so manually inputted an entry.

Sleep As Android is syncing sleep data to gfit but also doesn't populate to HA, though instead of the sensor state state being 'unknown' like HR, it always comes back completely blank. Perhaps each of these scopes has a separate issue?

cyberjunky commented 2 years ago

I have dug into it, and the call for sleep data is empty in the code, the integration is using the old Google Api calls, will have a look into the new Dataset calls

freitas666 commented 2 years ago

Good! I am updating my integration! In few minutes i back to say with we have successfully :-)

Enviado do meu iPhone

Em 6 de jun. de 2022, à(s) 16:42, Ron Klinkien @.***> escreveu:



Can you try version 1.0.7? I added the scopes and it kept working, i have no heart/sleep data to test with.

— Reply to this email directly, view it on GitHubhttps://github.com/cyberjunky/home-assistant-google_fit/issues/24#issuecomment-1147838008, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAQ7DLTXEWRIACHD64BZGDTVNZICJANCNFSM5V3KJRMQ. You are receiving this because you authored the thread.Message ID: @.***>

freitas666 commented 2 years ago

Actually i have a tickwatch ultra (smartwatch) with wear os. I have the app google fit installed and the own app of brand… both collect the information about sleep, heartrate, oxygen of blood, calories and many others dates. The most strange is only sleep time and heartrate not show in integration ….

Enviado do meu iPhone

Em 25 de mai. de 2022, à(s) 08:53, Ron Klinkien @.***> escreveu:

With which physical sensors do you measure them?