Skip to content

Commit

Permalink
Add Blood Glucose, Body Fat, Body Temperaure, and Basal Metabolic Rat…
Browse files Browse the repository at this point in the history
…e sensors (#74)
  • Loading branch information
lunarok authored Jul 24, 2023
1 parent 475a769 commit 85c03c0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ Platform | Name |Description
-- | -- | --
`sensor` | `active_minutes_daily` | [Active Minutes][active-minutes]. Reset daily.
`sensor` | `calories_burnt_daily` | [Calories burnt][calories-burnt] (kcal). Reset daily.
`sensor` | `basal_metabolic_rate` | [Base Metabolic Rate][basal-metabolic-rate] (kcal). Calories per day based on weight and activity.
`sensor` | `distance_travelled_daily` | [Distance travelled][distance-travelled] (metres). Reset daily.
`sensor` | `heart_points_daily` | [Heart Points][heart-points] earned. Reset daily.
`sensor` | `height` | [Height][height] (metres).
`sensor` | `weight` | [Weight][weight] (kilograms).
`sensor` | `body_fat` | [Body Fat][fat] (percentage).
`sensor` | `body_temperature` | [Body Temperature][temperature] (celcius).
`sensor` | `steps` | [Number of steps][steps] taken. Reset daily.
`sensor` | `deep_sleep` | [Deep sleep][sleep] time over the past 24 hours. May not be available depending on sleep data provider.
`sensor` | `light_sleep` | [Light sleep][sleep] time over the past 24 hours. May not be available depending on sleep data provider.
Expand All @@ -34,6 +37,7 @@ Platform | Name |Description
`sensor` | `blood_pressure_systolic` | Most recent Systolic [blood pressure][blood-pressure] reading.
`sensor` | `heart_rate` | Most recent [heart rate][heart-rate] measurement.
`sensor` | `resting_heart_rate` | Most recent resting [heart rate][heart-rate] measurement.
`sensor` | `blood_glucose` | Latest [blood_glucose][blood-glucose] measurement (mmol/L).
`sensor` | `hydration` | Total [water][hydration] consumed. Reset daily.
`sensor` | `oxygen_saturation` | The most recent [blood oxygen][blood-oxygen] saturation measurement.

Expand Down Expand Up @@ -171,13 +175,17 @@ If you want to contribute to this please read the [Contribution guidelines](CONT
<!--Links to Google Docs for detailed information on sensors -->
[active-minutes]: https://developers.google.com/fit/datatypes/activity#move_minutes
[calories-burnt]: https://developers.google.com/fit/datatypes/activity#calories_burned
[basal-metabolic-rate]: https://developers.google.com/fit/datatypes/activity#basal_metabolic_rate_bmr
[distance-travelled]: https://developers.google.com/fit/datatypes/location#distance_delta
[heart-points]: https://developers.google.com/fit/datatypes/activity#heart_points
[steps]: https://developers.google.com/fit/datatypes/activity#step_count_delta
[height]: https://developers.google.com/fit/datatypes/health#height
[weight]: https://developers.google.com/fit/datatypes/health#weight
[fat]: https://developers.google.com/fit/datatypes/health#body_fat_percentage
[temperature]: https://developers.google.com/fit/datatypes/health#body_temperature
[sleep]: https://developers.google.com/fit/datatypes/health#sleep
[heart-rate]: https://developers.google.com/fit/datatypes/health#heart_rate
[blood-pressure]: https://developers.google.com/fit/datatypes/health#blood_pressure
[blood-glucose]: https://developers.google.com/fit/datatypes/health#blood_glucose
[hydration]: https://developers.google.com/fit/datatypes/nutrition#hydration
[blood-oxygen]: https://developers.google.com/fit/datatypes/health#oxygen_saturation
8 changes: 8 additions & 0 deletions custom_components/google_fit/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,13 @@ def __init__(self):
lastUpdate=datetime.now(),
activeMinutes=None,
calories=None,
basalMetabolicRate=None,
distance=None,
heartMinutes=None,
height=None,
weight=None,
bodyFat=None,
bodyTemperature=None,
steps=None,
awakeSeconds=None,
sleepSeconds=None,
Expand All @@ -109,6 +112,7 @@ def __init__(self):
heartRateResting=None,
bloodPressureSystolic=None,
bloodPressureDiastolic=None,
bloodGlucose=None,
hydration=None,
oxygenSaturation=None,
)
Expand Down Expand Up @@ -266,9 +270,13 @@ def _parse_point(self, request_id: str, response: FitnessDataPoint) -> None:
if request_id in [
"height",
"weight",
"basalMetabolicRate",
"bodyFat",
"bodyTemperature",
"heartRate",
"heartRateResting",
"bloodPressureSystolic",
"bloodGlucose",
"oxygenSaturation",
]:
self.data[request_id] = self._get_latest_data_point(response)
Expand Down
4 changes: 4 additions & 0 deletions custom_components/google_fit/api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ class FitnessData(TypedDict):
lastUpdate: datetime
activeMinutes: float | None
calories: float | None
basalMetabolicRate: float | None
distance: float | None
heartMinutes: float | None
height: float | None
weight: float | None
bodyFat: float | None
bodyTemperature: float | None
steps: int | None
awakeSeconds: float | None
sleepSeconds: float | None
Expand All @@ -35,6 +38,7 @@ class FitnessData(TypedDict):
heartRateResting: float | None
bloodPressureSystolic: float | None
bloodPressureDiastolic: float | None
bloodGlucose: float | None
hydration: float | None
oxygenSaturation: float | None

Expand Down
43 changes: 43 additions & 0 deletions custom_components/google_fit/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
UnitOfMass,
UnitOfPressure,
UnitOfVolume,
UnitOfTemperature,
PERCENTAGE,
)

Expand All @@ -36,10 +37,12 @@
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/fitness.activity.read",
"https://www.googleapis.com/auth/fitness.body.read",
"https://www.googleapis.com/auth/fitness.body_temperature.read",
"https://www.googleapis.com/auth/fitness.nutrition.read",
"https://www.googleapis.com/auth/fitness.location.read",
"https://www.googleapis.com/auth/fitness.sleep.read",
"https://www.googleapis.com/auth/fitness.blood_pressure.read",
"https://www.googleapis.com/auth/fitness.blood_glucose.read",
"https://www.googleapis.com/auth/fitness.heart_rate.read",
"https://www.googleapis.com/auth/fitness.oxygen_saturation.read",
]
Expand Down Expand Up @@ -77,6 +80,16 @@
source="derived:com.google.calories.expended:com.google.android.gms:merge_calories_expended", # pylint: disable=line-too-long
data_key="calories",
),
GoogleFitSensorDescription(
key="google_fit",
name="Basal Metabolic Rate",
icon="mdi:target",
native_unit_of_measurement="kcal",
state_class=SensorStateClass.MEASUREMENT,
device_class=None,
source="derived:com.google.calories.bmr:com.google.android.gms:merged",
data_key="basalMetabolicRate",
),
GoogleFitSensorDescription(
key="google_fit",
name="Distance Travelled Daily",
Expand Down Expand Up @@ -117,6 +130,26 @@
source="derived:com.google.weight:com.google.android.gms:merge_weight",
data_key="weight",
),
GoogleFitSensorDescription(
key="google_fit",
name="Body Fat",
icon="mdi:scale-balance",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
device_class=None,
source="derived:com.google.body.fat.percentage:com.google.android.gms:merged",
data_key="bodyFat",
),
GoogleFitSensorDescription(
key="google_fit",
name="Body Temperature",
icon="mdi:thermometer",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE,
source="derived:com.google.body.temperature:com.google.android.gms:merged",
data_key="bodyTemperature",
),
GoogleFitSensorDescription(
key="google_fit",
name="Steps Daily",
Expand Down Expand Up @@ -216,6 +249,16 @@
source="derived:com.google.blood_pressure:com.google.android.gms:merged",
data_key="bloodPressureDiastolic",
),
GoogleFitSensorDescription(
key="google_fit",
name="Blood Glucose",
icon="mdi:water",
native_unit_of_measurement="mmol/L",
state_class=SensorStateClass.MEASUREMENT,
device_class=None,
source="derived:com.google.blood_glucose:com.google.android.gms:merged",
data_key="bloodGlucose",
),
GoogleFitSensorDescription(
key="google_fit",
name="Hydration",
Expand Down

0 comments on commit 85c03c0

Please sign in to comment.