From 4c94a14a598dd91de6172655fdd57752a9b4e05a Mon Sep 17 00:00:00 2001 From: Matthew Nessworthy Date: Sun, 12 Apr 2020 12:31:51 +0200 Subject: [PATCH] Only sync weight if it has a value --- sync.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/sync.py b/sync.py index dba7d5d..4bc500b 100755 --- a/sync.py +++ b/sync.py @@ -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()