Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Blood Glucose, Body Fat, Body Temperaure, and Basal Metabolic Rate sensors #74

Merged
merged 28 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ececfdd
Add Glucose sensor
lunarok Jul 15, 2023
c6da723
Add glucose sensor
lunarok Jul 15, 2023
d69ac73
Update api_types.py
lunarok Jul 15, 2023
6c6991e
Add temperature sensor
lunarok Jul 16, 2023
630a883
Add temperature sensor
lunarok Jul 16, 2023
d98918b
Update api_types.py
lunarok Jul 16, 2023
f0a163a
Add teperature in parsing method
lunarok Jul 16, 2023
c24cdc2
Correct datasourceid temperature
lunarok Jul 16, 2023
7e38f50
Adding fat %
lunarok Jul 16, 2023
5b081e2
Adding fat %
lunarok Jul 16, 2023
30b2589
Adding fat %
lunarok Jul 16, 2023
3d58eec
Adding BMR
lunarok Jul 16, 2023
a718f80
Adding BMR
lunarok Jul 16, 2023
ec58521
Adding BMR
lunarok Jul 16, 2023
40894be
Apply suggestions from code review
lunarok Jul 18, 2023
2f19b28
Update custom_components/google_fit/api.py
lunarok Jul 19, 2023
bb2e789
Update custom_components/google_fit/api.py
lunarok Jul 19, 2023
b7e6dbd
Update custom_components/google_fit/api_types.py
lunarok Jul 19, 2023
c263bde
Update custom_components/google_fit/api_types.py
lunarok Jul 19, 2023
c0914b1
Update custom_components/google_fit/const.py
lunarok Jul 19, 2023
7527af9
Update custom_components/google_fit/const.py
lunarok Jul 19, 2023
936b7f3
Update custom_components/google_fit/const.py
lunarok Jul 19, 2023
ec080a9
Update custom_components/google_fit/const.py
lunarok Jul 19, 2023
6ca1a47
Add new sensors
lunarok Jul 19, 2023
63ae313
Update README.md
lunarok Jul 23, 2023
286379d
Update README.md
lunarok Jul 23, 2023
b3039f4
Merge branch 'main' into main
lunarok Jul 23, 2023
1318b9b
Adding BMR and link to doc of new sensors
lunarok Jul 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
"fat",
lunarok marked this conversation as resolved.
Show resolved Hide resolved
"temperature",
lunarok marked this conversation as resolved.
Show resolved Hide resolved
"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
fat: float | None
lunarok marked this conversation as resolved.
Show resolved Hide resolved
temperature: float | None
lunarok marked this conversation as resolved.
Show resolved Hide resolved
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",
YorkshireIoT marked this conversation as resolved.
Show resolved Hide resolved
),
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="Fat",
lunarok marked this conversation as resolved.
Show resolved Hide resolved
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="fat",
lunarok marked this conversation as resolved.
Show resolved Hide resolved
),
GoogleFitSensorDescription(
key="google_fit",
name="Temperature",
lunarok marked this conversation as resolved.
Show resolved Hide resolved
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="temperature",
lunarok marked this conversation as resolved.
Show resolved Hide resolved
),
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