cyberjunky / home-assistant-garmin_connect

The Garmin Connect integration allows you to expose data from Garmin Connect to Home Assistant.
MIT License
238 stars 34 forks source link

Add service for body composition #116

Closed alexives closed 9 months ago

alexives commented 9 months ago

Related to https://github.com/cyberjunky/home-assistant-garmin_connect/issues/74, this adds a service for recording a weigh in/body composition using the add_body_composition method from python-garminconnect.

I'm running with this patch on my instance and it seems to work okay, though I haven't worked on a component before, so it's not impossible that this solution isn't ideal.

I don't have a lot of bandwidth to keep working on this, so if it needs edits it may take me a while to circle back. Alternately someone else is welcome to take this over the finish line 😅

cyberjunky commented 9 months ago

Thanks a lot!

borpin commented 9 months ago

This is great, but from the sample automation, it seems to require you to use the weight sensor created by the add-on itself which seems a little odd as that would be reading the data from Garmin Connect. The Sample data in the Developer tools has this as the YAML;

service: garmin_connect.add_body_composition
data:
  weight: 82.3
  timestamp: "2023-12-30T07:34:00.000Z"
  bmi: 24.7
  percent_fat: 23.6
  percent_hydration: 51.2
  visceral_fat_mass: 45.3
  bone_mass: 10.1
  muscle_mass: 15.2
  basal_met: 1900
  active_met: 840
  physique_rating: 28
  metabolic_age: 37
  visceral_fat_rating: 10

I have most of this data from my MiScale in HA and would like to send it on to GC.

Any further insights?

alexives commented 9 months ago

@borpin take a look at the example added here - https://github.com/cyberjunky/home-assistant-garmin_connect#set-up-an-automation-using-the-garmin_connectadd_body_composition-service

borpin commented 9 months ago

My point is, I don't think you need the 'entity_ID' entry on the service. The weight sensor you have force someone to use is the one read from GC. The service just needs the data fields to send to GC.