mirror of
https://github.com/cyberjunky/home-assistant-garmin_connect.git
synced 2026-01-09 12:57:58 -05:00
Added Training Readiness sensor Training Status sensor Lactate Threshold HR sensor and Lactate Threshold Speed sensor
This commit is contained in:
@@ -117,6 +117,10 @@ Sensor values depend on your Garmin devices and connected apps.
|
|||||||
| Fitness Age | Estimated fitness age |
|
| Fitness Age | Estimated fitness age |
|
||||||
| Chronological Age | Your actual age |
|
| Chronological Age | Your actual age |
|
||||||
| Endurance Score | Overall endurance rating |
|
| Endurance Score | Overall endurance rating |
|
||||||
|
| Training Readiness | Training readiness score (%) |
|
||||||
|
| Training Status | Current training status phrase |
|
||||||
|
| Lactate Threshold HR | Lactate threshold heart rate (bpm) |
|
||||||
|
| Lactate Threshold Speed | Lactate threshold running pace (m/s) |
|
||||||
|
|
||||||
### Activity Tracking
|
### Activity Tracking
|
||||||
|
|
||||||
|
|||||||
@@ -196,6 +196,33 @@ class GarminConnectDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
badges = await self.hass.async_add_executor_job(self.api.get_earned_badges)
|
badges = await self.hass.async_add_executor_job(self.api.get_earned_badges)
|
||||||
summary["badges"] = badges
|
summary["badges"] = badges
|
||||||
|
|
||||||
|
# Fetch training readiness
|
||||||
|
try:
|
||||||
|
training_readiness = await self.hass.async_add_executor_job(
|
||||||
|
self.api.get_training_readiness, today.isoformat()
|
||||||
|
)
|
||||||
|
summary["trainingReadiness"] = training_readiness
|
||||||
|
except Exception:
|
||||||
|
summary["trainingReadiness"] = {}
|
||||||
|
|
||||||
|
# Fetch training status
|
||||||
|
try:
|
||||||
|
training_status = await self.hass.async_add_executor_job(
|
||||||
|
self.api.get_training_status, today.isoformat()
|
||||||
|
)
|
||||||
|
summary["trainingStatus"] = training_status
|
||||||
|
except Exception:
|
||||||
|
summary["trainingStatus"] = {}
|
||||||
|
|
||||||
|
# Fetch lactate threshold
|
||||||
|
try:
|
||||||
|
lactate_threshold = await self.hass.async_add_executor_job(
|
||||||
|
self.api.get_lactate_threshold
|
||||||
|
)
|
||||||
|
summary["lactateThreshold"] = lactate_threshold
|
||||||
|
except Exception:
|
||||||
|
summary["lactateThreshold"] = {}
|
||||||
|
|
||||||
user_points = sum(
|
user_points = sum(
|
||||||
badge["badgePoints"] * badge["badgeEarnedNumber"] for badge in badges
|
badge["badgePoints"] * badge["badgeEarnedNumber"] for badge in badges
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -861,6 +861,53 @@ ACTIVITY_TRACKING_SENSORS: tuple[GarminConnectSensorEntityDescription, ...] = (
|
|||||||
"last_workouts": data.get("workouts", [])[-10:],
|
"last_workouts": data.get("workouts", [])[-10:],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
GarminConnectSensorEntityDescription(
|
||||||
|
key="trainingReadiness",
|
||||||
|
translation_key="training_readiness",
|
||||||
|
icon="mdi:run-fast",
|
||||||
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
|
||||||
|
value_fn=lambda data: data.get("trainingReadiness", {}).get("score")
|
||||||
|
if isinstance(data.get("trainingReadiness"), dict)
|
||||||
|
else (data.get("trainingReadiness", [{}])[0].get("score")
|
||||||
|
if isinstance(data.get("trainingReadiness"), list) and data.get("trainingReadiness")
|
||||||
|
else None),
|
||||||
|
attributes_fn=lambda data: data.get("trainingReadiness", {})
|
||||||
|
if isinstance(data.get("trainingReadiness"), dict)
|
||||||
|
else (data.get("trainingReadiness", [{}])[0]
|
||||||
|
if isinstance(data.get("trainingReadiness"), list) and data.get("trainingReadiness")
|
||||||
|
else {}),
|
||||||
|
),
|
||||||
|
GarminConnectSensorEntityDescription(
|
||||||
|
key="trainingStatus",
|
||||||
|
translation_key="training_status",
|
||||||
|
icon="mdi:chart-line",
|
||||||
|
|
||||||
|
value_fn=lambda data: data.get("trainingStatus", {}).get("trainingStatusPhrase"),
|
||||||
|
attributes_fn=lambda data: data.get("trainingStatus", {}),
|
||||||
|
),
|
||||||
|
GarminConnectSensorEntityDescription(
|
||||||
|
key="lactateThresholdHeartRate",
|
||||||
|
translation_key="lactate_threshold_hr",
|
||||||
|
icon="mdi:heart-pulse",
|
||||||
|
native_unit_of_measurement="bpm",
|
||||||
|
|
||||||
|
value_fn=lambda data: data.get("lactateThreshold", {}).get(
|
||||||
|
"speed_and_heart_rate", {}
|
||||||
|
).get("heartRate"),
|
||||||
|
attributes_fn=lambda data: data.get("lactateThreshold", {}),
|
||||||
|
),
|
||||||
|
GarminConnectSensorEntityDescription(
|
||||||
|
key="lactateThresholdSpeed",
|
||||||
|
translation_key="lactate_threshold_speed",
|
||||||
|
icon="mdi:speedometer",
|
||||||
|
native_unit_of_measurement="m/s",
|
||||||
|
|
||||||
|
value_fn=lambda data: data.get("lactateThreshold", {}).get(
|
||||||
|
"speed_and_heart_rate", {}
|
||||||
|
).get("speed"),
|
||||||
|
attributes_fn=lambda data: data.get("lactateThreshold", {}),
|
||||||
|
),
|
||||||
GarminConnectSensorEntityDescription(
|
GarminConnectSensorEntityDescription(
|
||||||
key="badges",
|
key="badges",
|
||||||
translation_key="badges",
|
translation_key="badges",
|
||||||
|
|||||||
@@ -343,6 +343,18 @@
|
|||||||
"last_workouts": {
|
"last_workouts": {
|
||||||
"name": "Last workouts"
|
"name": "Last workouts"
|
||||||
},
|
},
|
||||||
|
"training_readiness": {
|
||||||
|
"name": "Training readiness"
|
||||||
|
},
|
||||||
|
"training_status": {
|
||||||
|
"name": "Training status"
|
||||||
|
},
|
||||||
|
"lactate_threshold_hr": {
|
||||||
|
"name": "Lactate threshold heart rate"
|
||||||
|
},
|
||||||
|
"lactate_threshold_speed": {
|
||||||
|
"name": "Lactate threshold speed"
|
||||||
|
},
|
||||||
"badges": {
|
"badges": {
|
||||||
"name": "Badges"
|
"name": "Badges"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -100,6 +100,10 @@ This integration provides **110+ sensors** covering various health and fitness m
|
|||||||
|
|
||||||
- **Fitness Age** - Estimated fitness age
|
- **Fitness Age** - Estimated fitness age
|
||||||
- **Endurance Score** - Overall endurance rating
|
- **Endurance Score** - Overall endurance rating
|
||||||
|
- **Training Readiness** - Training readiness score (%)
|
||||||
|
- **Training Status** - Current training status phrase
|
||||||
|
- **Lactate Threshold HR** - Lactate threshold heart rate (bpm)
|
||||||
|
- **Lactate Threshold Speed** - Lactate threshold running pace (m/s)
|
||||||
|
|
||||||
### Workouts
|
### Workouts
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user