mirror of
https://github.com/cyberjunky/home-assistant-garmin_connect.git
synced 2026-01-08 04:23:56 -05:00
added blood_pressure function
This commit is contained in:
@@ -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)
|
||||
)
|
||||
|
||||
@@ -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."""
|
||||
|
||||
|
||||
@@ -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"
|
||||
Reference in New Issue
Block a user