Google Fit Support

The gist should work as a custom component, but you’ll need to edit some of the values to make it work for you. Specifically, you’ll need to edit the client_id and secret. These values you’ll get by setting up an app and making sure the fit api is enabled. You should be able to use the https://home-assistant.io/components/calendar.google/ instructions as a guide

edit: I just edited the gist to add a fix that could be causing some warnings in the logs

2 Likes

Hi @wardcraigj are you planning on making this an official component?

1 Like

I don’t have any immediate plans to. I’ve noticed it’s not super consistent in pulling steps, so that would require some work, also all the client logic would need to get pulled out and implemented in it’s own library that gets pulled in as a requirement in order for the component to be accepted. I don’t have any really useful automations that use it in my set-up, so I don’t really want to commit to maintaining and supporting it, but if someone wants to build it out, I’d be happy to offer any sort of assistance that I can

Thanks Craig. That makes sense.

I was trying to achieve something similar. Mainly focused on weight, but happy to see if it can be extended for other attributes.

This is my custom_compoments/sensor/google_fit.py:

While it is focused on weight, it could be updated to other type of data by changing:
API_SCOPE = ‘https://www.googleapis.com/auth/fitness.body.read
and
weight_datasources = self._get_datasources(‘com.google.weight’)
(as well as selecting the right attributes afterwards)

I hope it is useful.
If someone wants to partner to extend this and integrate it natively, happy to do so.

Cheers,
Nito

1 Like

Thanks @nitobuendia I was able to get Steps, move time, distance and weight with modifications in your script.
Here is my version of the custom_component
https://github.com/hemantkamalakar/haconfigs/blob/master/custom_components/sensor/google_fit.py

You mean i can use the same client_id and client_secret i use woth google calendar or must i create another ones for Google Fit?

Is this component still in use? I added and was prompted to enter my code but sensors are not added.

Yes. You have to create client_id and client_secret for Google Fit.

I have managed to get authentication and sensors are added but they always state unknown.

Yes. In fact I have added more sensors now. Now it supports
- steps
- distance
- time
- calories
- weight
- height

3 Likes

You know what it is now populating lol what is the poll time for these sensors I swear it been up for a few days and even this morning they were still unknown state.

Is it possible to get the latest version of your component?

I have just pushed the updates to my Github repo.
https://github.com/hemantkamalakar/haconfigs/blob/master/custom_components/sensor/google_fit.py

This is how i defined the configuraations for the component.

  • platform: google_fit
    client_id: !secret google_client_id
    client_secret: !secret google_client_secret
    scan_interval: 30
3 Likes

thank you very much for this, was at it for a bit last night glad to have it up and running.

It seems doesn’t work anymore after the 0.85.6 update. Is still working for you with this release?

@hemantkamalakar thanks for sharing the component.

I’m using the latest update but only have the folowing sensors:

  • weight
  • height
  • distance
  • time

How to get steps and calories?

Can this be adapted to the iPhone? Or there is another way to show steps from an iPhone device

Ok so this is what I have so far thanks again @hemantkamalakar

@maurizio53 This component is working for me on 0.84.6 is this what you mean or are you running a beta release? If so you can’t surely expect support running on beta.

2 Likes

Thanks a lot @jimpower. Had a look at your github repo. You have a great home assistant setup.

1 Like

I have my sleep being synced with google fit also do you think you could help me to get this sensor also? I had a look at the google api and there is a call for sleep data but I can’t seem to find it at the moment.