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
Python calculator made with tkinter package

Python-Calculator Python calculator made with tkinter package. works both on Visual Studio Code Or Any Other Ide Or You Just Copy paste The Same Thing

Pro_Gamer_711 1 Nov 11, 2021
python scripts - mostly automation scripts

python python scripts - mostly automation scripts You can set your environment in various ways bash #!/bin/bash python - locally on remote host #!/bi

Enyi 1 Jan 05, 2022
A tool to nowcast quarterly data with monthly indicators: US consumption example

MIDAS_Nowcaster A tool to nowcast quarterly data with monthly indicators: US consumption example Pulls data directly from FRED from a list of codes -

Gene Kindberg-Hanlon 3 Oct 06, 2022
Open source home automation that puts local control and privacy first

Home Assistant Open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiast

Home Assistant 57k Jan 02, 2023
A simple but fully functional calculator that will take multiple operations.

Functional-Calculator A simple but fully functional calculator that will take multiple operations. Usage Run the following command through terminal: p

Uzziel Ariel 1 Dec 22, 2022
HashDB Binary Ninja Plugin

HashDB Plugin (v0.1) Author: Vector 35 Inc Plugin for interacting with the OALABS HashDB service. Description: Plugin that can be used to lookup hashe

Jordan 3 Jul 30, 2022
Library to generate random strings from regular expressions.

Xeger Library to generate random strings from regular expressions. To install, type: pip install xeger To use, type: from xeger import Xeger

Colm O'Connor 101 Nov 15, 2022
This program generates automatically new folders containing old version of program

Automated Folder Versions Generator by Sergiy Grimoldi - V.0.0.2 This program generates automatically new folders containing old version of something

Sergiy Grimoldi 1 Dec 23, 2021
AIO solution for SSIS students

ssis.bit AIO solution for SSIS students Hardware CircuitPython supports more than 200 different boards. Locally available is the TTGO T8 ESP32-S2 ST77

3 Jun 05, 2022
Remote Worker

Remote Worker Separation of Responsibilities There are several reasons to move some processing out of the main code base for security or performance:

V2EX 69 Dec 05, 2022
Viewflow is an Airflow-based framework that allows data scientists to create data models without writing Airflow code.

Viewflow Viewflow is a framework built on the top of Airflow that enables data scientists to create materialized views. It allows data scientists to f

DataCamp 114 Oct 12, 2022
MDAnalysis tool to calculate membrane curvature.

The MDAkit for membrane curvature analysis is part of the Google Summer of Code program and it is linked to a Code of Conduct.

MDAnalysis 19 Oct 20, 2022
LTGen provides classic algorithms used in Language Theory.

LTGen LTGen stands for Language Theory GENerator and provides tools to implement language theory. Command Line LTGen is a collection of tools to imple

Hugues Cassé 1 Jan 07, 2022
Quanser Labs Robotic Arm With Python

Quanser-Labs-Robotic-Arm As a team, we programmed a Robotic-Arm in Python on the

1 Jul 11, 2022
Custom python interface to xstan (a modified (cmd)stan)

Custom python interface to xstan (a modified (cmd)stan) Use at your own risk, currently everything is very brittle and will probably be changed in the

2 Dec 16, 2021
Calc.py - A powerful Python REPL calculator

Calc - A powerful Python REPL calculator This is a calculator with a complex sou

Alejandro 8 Oct 22, 2022
A tool for generating skill map/tree like diagram

skillmap A tool for generating skill map/tree like diagram. What is a skill map/tree? Skill tree is a term used in video games, and it can be used for

Yue 98 Jan 07, 2023
Simple GUI menu for micropython using a rotary encoder and basic display.

Micropython encoder based menu This is a simple menu system written in micropython. It uses a switch, a rotary encoder and an OLED display.

80 Jan 07, 2023
An Embedded Linux Project Build and Compile Tool -- An Bitbake UI Extension

Dianshao - An Embedded Linux Project Build and Compile Tool

0 Mar 27, 2022