Skip to content

Commit

Permalink
Merge pull request #36 from AiiR42/json-numbers
Browse files Browse the repository at this point in the history
Use numbers in json for numeric values.
  • Loading branch information
lolouk44 authored Nov 23, 2020
2 parents 698d2f1 + c2952c3 commit 6c986a7
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Xiaomi_Scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,23 @@ def _publish(self, weight, unit, mitdatetime, hasImpedance, miimpedance):

lib = Xiaomi_Scale_Body_Metrics.bodyMetrics(calcweight, height, age, sex, 0)
message = '{'
message += '"weight":"' + "{:.2f}".format(weight) + '"'
message += '"weight":' + "{:.2f}".format(weight)
message += ',"weight_unit":"' + str(unit) + '"'
message += ',"bmi":"' + "{:.2f}".format(lib.getBMI()) + '"'
message += ',"basal_metabolism":"' + "{:.2f}".format(lib.getBMR()) + '"'
message += ',"visceral_fat":"' + "{:.2f}".format(lib.getVisceralFat()) + '"'
message += ',"bmi":' + "{:.2f}".format(lib.getBMI())
message += ',"basal_metabolism":' + "{:.2f}".format(lib.getBMR())
message += ',"visceral_fat":' + "{:.2f}".format(lib.getVisceralFat())

if hasImpedance:
lib = Xiaomi_Scale_Body_Metrics.bodyMetrics(calcweight, height, age, sex, int(miimpedance))
bodyscale = ['Obese', 'Overweight', 'Thick-set', 'Lack-exerscise', 'Balanced', 'Balanced-muscular', 'Skinny', 'Balanced-skinny', 'Skinny-muscular']
message += ',"lean_body_mass":"' + "{:.2f}".format(lib.getLBMCoefficient()) + '"'
message += ',"body_fat":"' + "{:.2f}".format(lib.getFatPercentage()) + '"'
message += ',"water":"' + "{:.2f}".format(lib.getWaterPercentage()) + '"'
message += ',"bone_mass":"' + "{:.2f}".format(lib.getBoneMass()) + '"'
message += ',"muscle_mass":"' + "{:.2f}".format(lib.getMuscleMass()) + '"'
message += ',"protein":"' + "{:.2f}".format(lib.getProteinPercentage()) + '"'
message += ',"lean_body_mass":' + "{:.2f}".format(lib.getLBMCoefficient())
message += ',"body_fat":' + "{:.2f}".format(lib.getFatPercentage())
message += ',"water":' + "{:.2f}".format(lib.getWaterPercentage())
message += ',"bone_mass":' + "{:.2f}".format(lib.getBoneMass())
message += ',"muscle_mass":' + "{:.2f}".format(lib.getMuscleMass())
message += ',"protein":' + "{:.2f}".format(lib.getProteinPercentage())
message += ',"body_type":"' + str(bodyscale[lib.getBodyType()]) + '"'
message += ',"metabolic_age":"' + "{:.0f}".format(lib.getMetabolicAge()) + '"'
message += ',"metabolic_age":' + "{:.0f}".format(lib.getMetabolicAge())

message += ',"timestamp":"' + mitdatetime + '"'
message += '}'
Expand Down

0 comments on commit 6c986a7

Please sign in to comment.