added blood_pressure function

This commit is contained in:
kruemelro
2024-04-05 09:43:52 +02:00
parent 09e80e4255
commit 47096eabeb
3 changed files with 55 additions and 0 deletions

View File

@@ -257,3 +257,18 @@ class GarminConnectDataUpdateCoordinator(DataUpdateCoordinator):
service_data.data.get("visceral_fat_rating", None),
service_data.data.get("bmi", None)
)
async def add_blood_pressure(self, entity, service_data):
"""Record a blood pressure measurement"""
if not await self.async_login():
raise IntegrationError(
"Failed to login to Garmin Connect, unable to update"
)
await self.hass.async_add_executor_job(
self._api.set_blood_pressure,
service_data.data.get("systolic"),
service_data.data.get("diastolic"),
service_data.data.get("pulse"),
service_data.data.get("note", None)
)

View File

@@ -108,6 +108,10 @@ async def async_setup_entry(
"add_body_composition", BODY_COMPOSITION_SERVICE_SCHEMA, coordinator.add_body_composition
)
platform.async_register_entity_service(
"add_blood_pressure", BLOOD_PRESSURE_SERVICE_SCHEMA, coordinator.add_blood_pressure
)
ENTITY_SERVICE_SCHEMA = vol.Schema(
{
vol.Required(ATTR_ENTITY_ID): str,
@@ -135,6 +139,17 @@ BODY_COMPOSITION_SERVICE_SCHEMA = vol.Schema(
}
)
BLOOD_PRESSURE_SERVICE_SCHEMA = vol.Schema(
{
vol.Required(ATTR_ENTITY_ID): str,
vol.Required("systolic"): float,
vol.Required("diastolic"): float,
vol.Required("pulse"): float,
vol.Optional("note"): str
}
)
class GarminConnectSensor(CoordinatorEntity, SensorEntity):
"""Representation of a Garmin Connect Sensor."""

View File

@@ -114,3 +114,28 @@ add_body_composition:
entity:
integration: garmin_connect
device_class: weight
add_blood_pressure:
name: Adds updated blood pressure metrics
description: Adds updated blood pressure metrics.
fields:
systolic:
required: true
name: Systolic
description: Systolic value
example: 120
diastolic:
required: true
name: Diastolic
description: Diastolic value
example: 80
pulse:
required: true
name: Pulse
description: Pulse
example: 60
notes:
required: false
name: Notes
description: Add a note to the measurement
example: "Measured with Beurer BC54"