Skip to content
This repository has been archived by the owner on Nov 14, 2020. It is now read-only.

Only sync weight if it has a value #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
34 changes: 18 additions & 16 deletions sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,24 @@ def verbose_print(s):

dt = group.get_datetime()
weight = group.get_weight()
fat_ratio = group.get_fat_ratio()
muscle_mass = group.get_muscle_mass()
hydration = group.get_hydration()
bone_mass = group.get_bone_mass()

fit.write_device_info(timestamp=dt)
fit.write_weight_scale(timestamp=dt,
weight=weight,
percent_fat=fat_ratio,
percent_hydration=(hydration*100.0/weight) if (hydration and weight) else None,
bone_mass=bone_mass,
muscle_mass=muscle_mass
)
verbose_print('appending weight scale record... %s %skg %s%%\n' % (dt, weight, fat_ratio))
last_dt = dt
last_weight = weight
if weight:
fat_ratio = group.get_fat_ratio()
muscle_mass = group.get_muscle_mass()
hydration = group.get_hydration()
bone_mass = group.get_bone_mass()

fit.write_device_info(timestamp=dt)
fit.write_weight_scale(timestamp=dt,
weight=weight,
percent_fat=fat_ratio,
percent_hydration=(hydration*100.0/weight) if (hydration and weight) else None,
bone_mass=bone_mass,
muscle_mass=muscle_mass
)
verbose_print('appending weight scale record... %s %s %s %s %s %s \n' % (dt, weight, fat_ratio, muscle_mass, hydration, bone_mass))
last_dt = dt
last_weight = weight

fit.finish()


Expand Down