Google Fit Sensor Component

Overview

hacs_badge made-with-python Donate

Google Fit Sensor Component

Based on

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

  • steps
  • distance
  • time
  • calories
  • weight
  • height
  • sleep
  • heartrate
  • oxygen
  • blood pressure
  • nutrition
  • hydratation
  • BMR

Installation

HACS - Recommended

  • Have HACS installed, this will allow you to easily update.
  • Add https://github.com/IvanVojtko/googlefit-homeassistant 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 /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

Google Fit credentials

In order to generate credentials.json, 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. Add all Fitness API read scopes. After generating credentials, download credentials.json file and place it into this directory, next to get_credentials.py In oder to enable Fitness API open Google Cloud console: https://console.cloud.google.com/apis/library/fitness.googleapis.com and enable API.

To allow HA access your Fit data, you need to complete a challenge. It can't be completed by HA so that's why you need to use get_credentials.py script. First install all the requirements using python -m pip install -r requirements.txt. Then run script python get_credentials.py, open the generated URL, allow access and don't forget to tick mark all permissions. This script will generate .google_fit.token file. Copy this file to your HA configuration directory.

Sensors

Sensor name Entity
Steps sensor.google_steps
Calories sensor.google_calories
Distance sensor.google_distance
Heart rate sensor.google_heart_rate
Resting heart rate sensor.google_resting_heart_rate
Move time sensor.google_move_time
Blood oxygen sensor.google_oxygen
Sleep sensor.google_sleep
Blood pressure SYS sensor.google_blood_pressure_sys
Blood pressure DIA sensor.google_blood_pressure_dia
Hydratation sensor.google_hydratation
BMR sensor.google_bmr

Attributes

Attribute name Entity Attribute
Potassium sensor.google_nutrition potassium
Calcium sensor.google_nutrition calcium
Vitamin A sensor.google_nutrition vitamin_a
Vitamin C sensor.google_nutrition vitamin_c
Total carbs sensor.google_nutrition carbs.total
Polyunsaturated fat sensor.google_nutrition fat.polyunsaturated
Monounsaturated fat sensor.google_nutrition fat.monounsaturated
Calories sensor.google_nutrition calories
Trans fat sensor.google_nutrition fat.trans
Total fat sensor.google_nutrition fat.total
Sodium sensor.google_nutrition sodium
Saturated fat sensor.google_nutrition fat.saturated
Protein sensor.google_nutrition protein
Cholesterol sensor.google_nutrition cholesterol
Iron sensor.google_nutrition iron
Sugar sensor.google_nutrition sugar
Dietary fiber sensor.google_nutrition dietary_fiber

Comments
  • .google_fit.token format

    .google_fit.token format

    When I run python3 get_credentials.py the resulting token is in some strange format that Home Assistant doesn't like.

    <80>^D<95><80>^D^@^@^@^@^@^@<8c>^Ygoogle.oauth2.credentials<94><8c>^KCredentials<94><93><94>)<81><94>}<94>(<8c>^Etoken<94><8c>TOKEN REMOVED<94><8c>^Fexpiry<94><8c>^Hdatetime<94><8c>^Hdatetime<94><93><94>C
    ^Gæ^B^D^V^P^\^N9<87><94><85><94>R<94><8c>^Q_quota_project_id<94>N<8c>^G_scopes<94>]<94>
    ...
    

    I'm assuming this should be a JSON string. @IvanVojtko Can you point me in the right direction to generating a proper token?

    opened by Terit 3
  • Redirect to localhost:8080 after OAuth Consent Screen

    Redirect to localhost:8080 after OAuth Consent Screen

    When i access the URL generated by get_credentials.py and check all permissions and click Continue i get redirected to a URL like http://localhost:8080/?state=rYmM5PTvl7MbN... and the script will not generate a .google_fit.token. When i check the generated URL, there is a "redirect_uri" parameter which specifies the localhost:8080.

    Did i miss something in the configuration?

    // Edit: I found, that in the credentials.json the "redirect_url" to localhost is specified. I changed it to my external HA domain, but then Google gives the error "Redirect URI mismatch".

    opened by remklov 1
  • installation

    installation

    Hallo, thank's for Your job, I've follow all the procedure, but finally I have no idea that how i can finalize the HA data access, please, can You explain step by step how i can run script and optain authorisations?! Thank's in advance, Gdi

    opened by Gdii 1
  • Question about multiple Google Fit users

    Question about multiple Google Fit users

    I was able to get your integration working today and it is very cool! Thank you for creating this. I am wondering if it is possible to pull Fit data from to different Google accounts? I'd really love to be able to pull stats from my Fit as well as my girlfriends. Perhaps multiple .google_fit.token? Thanks in advance!

    opened by Andrewdlec 3
  • Error 400: invalid_request

    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?

    opened by baldachyn 11
  • Question about Fit heartrate reporting and update interval

    Question about Fit heartrate reporting and update interval

    Hi! First, thank you for creating this integration. I've only been using it for a bit over a day now, but I've been really enjoying it so far.

    The only maybe-issue I'm running into so far is with the Google Fit heart rate sensor. Specifically, for me, it seems to update very irregularly - often only once every several hours - and the resulting data and history in Home Assistant have little in common with the data that's visible in Google Fit directly.

    Here's an example, with my February 8th heart rate data as shown in the Fit app overlaid on a graph of the same time period in Home Assistant.

    GFit Heartrate

    I'm new to all of this, but especially the Google API stuff (I just fumbled through the API instructions, I think correctly), so I don't know if this 'problem' is something I did wrong, or something up with the integration, or if this data is just as good as Google is willing to offer.

    Any help or insight on how to get better heartrate data (or just confirmation that this is as good as it gets, disappointing as that would be) is greatly appreciated.

    opened by NCC1941 5
Releases(v0.0.4)
Owner
Ivan Vojtko
Ivan Vojtko
A repository of study materials related to Think Python 2nd Edition by Allen B. Downey. More information about the book can be found here: https://greenteapress.com/wp/think-python-2e/

Intro-To-Python This content is based on the book Think Python 2nd Edition by Allen B. Downey. More information about the book can be found here: http

Brent Eskridge 63 Jan 07, 2023
Automator anble you to create automations on your system

WELCOME TO AUTOMATOR BETA This programm is able to create automations on your system. This programm is only an experimantal release; infact it works v

Davide 1 Jan 12, 2022
nbsafety adds a layer of protection to computational notebooks by solving the stale dependency problem when executing cells out-of-order

nbsafety adds a layer of protection to computational notebooks by solving the stale dependency problem when executing cells out-of-order

150 Jan 07, 2023
Extract gene length based on featureCount calculation gene nonredundant exon length method.

Extract gene length based on featureCount calculation gene nonredundant exon length method.

laojunjun 12 Nov 21, 2022
Programming labs for 6.S060 (Foundations of Computer Security).

6.S060 Labs This git repository contains the code for the labs in 6.S060. In these labs, you will add a series of security features to a photo-sharing

MIT PDOS 10 Nov 02, 2022
Run-Your-Own Firefox Sync Server

Run-Your-Own Firefox Sync Server This is an all-in-one package for running a self-hosted Firefox Sync server. It bundles the "tokenserver" project for

Mozilla Services 1.7k Dec 30, 2022
Let’s Play with Python3

Python3-FirstEdition a bunch of python programs and stuff Super Important Notice THIS IS LICENSED UNDER GNU PUBLIC LICENSE V3 also, refer to Contribut

Jym Patel 2 Nov 24, 2022
A proof-of-concept package manager for Cairo contracts/libraries

glyph A proof-of-concept package manager for Cairo contracts/libraries. Distribution through pypi. Installation through existing package managers -- p

Sam Barnes 11 Jun 06, 2022
Download and archive entire usenet newsgroups over NNTP.

Usenet Archiving Tool This code is for archiving Usenet discussions, not downloading files. Newsgroup posts are saved under the authors name and email

Corey White 2 Dec 23, 2021
A Python script to delete movies with a certain tag after a certain amount of days.

radarr_autodelete Simple script, which deletes movies with a specific tag after a certain amount of days Pip Packages pip3 install pyarr python-dotenv

7 Dec 06, 2022
Shared utility scripts for AI for Earth projects and team members

Overview Shared utilities developed by the Microsoft AI for Earth team The general convention in this repo is that users who want to consume these uti

Microsoft 38 Dec 30, 2022
SWS Filters App - SWS Filters App With Python

SWS Filters App Fun πŸ˜… ... Fun πŸ˜… Click On photo and see πŸ˜‚ πŸ˜‚ πŸ˜‚ Your Video rec

Sagar Jangid 3 Jul 07, 2022
Convert Photoshop curves (acv) to xmp presets for Lightroom

acv2xmp Convert Photoshop curves (acv) to Lightroom preset (xmp) acv2xmp.py Basic command prompt that relies on standard library only and can be used

5 Feb 06, 2022
Collection of tools to be more productive in your work environment and to avoid certain repetitive tasks. πŸ’›πŸ’™πŸ’š

Collection of tools to be more productive in your work environment and to avoid certain repetitive tasks. πŸ’›πŸ’™πŸ’š

Raja Rakotonirina 2 Jan 10, 2022
Minutaria is a basic educational Python timer used to learn python and software testing libraries.

minutaria minutaria is a basic educational Python timer. The project is educational, it aims to teach myself programming, python programming, python's

1 Jul 16, 2021
Simple tooling for marking deprecated functions or classes and re-routing to the new successors' instance.

pyDeprecate Simple tooling for marking deprecated functions or classes and re-routing to the new successors' instance

Jirka Borovec 45 Nov 24, 2022
Laurence Billingham 1 Feb 16, 2022
Awesome Casino is simple offline casino made on python.

Awesome-Casino Awesome Casino is simple offline casino made on python. I found bug, what can i do? If you find any bug or want to suggest any idea, al

Herman 1 Feb 04, 2022
Improve current data preprocessing for FTM's WOB data to analyze Shell and Dutch Governmental contacts.

We're the hackathon leftovers, but we are Too Good To Go ;-). A repo by Lukas Schubotz and Raymon van Dinter. We aim to improve current data preprocessing for FTM's WOB data to analyze Shell and Dutc

ASReview hackathon for Follow the Money 5 Dec 09, 2021
Semester Project on Signal Processing @CS UCU 2021

Blur Detection with Haar Wavelet Transform Requirements Python3 opencv-python PyWavelets Install these using the following command: $ pip install -r r

ButynetsD 2 Oct 15, 2022