You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thanks for the perfect working solution. Can you help me finish what I started?
Goal: not just get only MQTT, but also have the ability to upload values to Garmin connect.
Reference: https://github.com/RobertWojtowicz/miscale2garmin has a very similar code with only several changes. We could add this as a feature to your repo.
Two ways I could reach the needed result:
Ask you to post impedance raw to MQTT topic. Then I would be running Robert's script locally reading from MQTT and posting to Garmin from cronned Linux script. Cons is that every calculation done in this integration would be redone once again.
Add Garmin posting of results to your repo. Here's what I see viable to do (but totally lack python skills to debug and do it correctly):
2.1 To configuration file: Add a boolean, SENDTOGARMIN: false (to control whether this will get executed or not)
2.2 To configuration file: Add a string to USERS, GARMINCONNECTPASSWORD: "..." for each user to be available to send to his own account.
2.3 Add a file, which seems to do the raw Garmin export: https://github.com/RobertWojtowicz/miscale2garmin/blob/master/bodycomposition
2.4 After MQTT send, add a code similar to:
Calculate metrics and send to garmin connect
if selected_user is not None and SENDTOGARMIN is true and GARMINCONNECTPASSWORD is not empty:
lib = Xiaomi_Scale_Body_Metrics.bodyMetrics(weight, selected_user.height, selected_user.age, selected_user.sex, int(miimpedance))
bone_percentage = (lib.getBoneMass() / weight) * 100
muscle_percentage = (lib.getMuscleMass() / weight) * 100
message = (path) + '/bodycomposition upload '
message += '--bone ' + "{:.2f}".format(bone_percentage) + ' '
message += '--calories ' + "{:.2f}".format(lib.getBMR()) + ' '
message += '--bmi ' + "{:.2f}".format(lib.getBMI()) + ' '
message += '--email ' + selected_user.email + ' '
message += '--fat ' + "{:.2f}".format(lib.getFatPercentage()) + ' '
message += '--hydration ' + "{:.2f}".format(lib.getWaterPercentage()) + ' '
message += '--metabolic-age ' + "{:.0f}".format(lib.getMetabolicAge()) + ' '
message += '--muscle ' + "{:.2f}".format(muscle_percentage) + ' '
message += '--password ' + selected_user.password + ' '
message += '--physique-rating ' + "{:.2f}".format(lib.getBodyType()) + ' '
message += '--unix-timestamp ' + mitdatetime + ' '
message += '--visceral-fat ' + "{:.2f}".format(lib.getVisceralFat()) + ' '
message += '--weight ' + "{:.2f}".format(weight) + ' '
os.system(message)
print("Processed file: " + (mitdatetime) + ".tlog")
I assume the changes are minimal and I would be glad to do the testing if you would be willing to help :)
Please let me know if it's something that could be done.
The text was updated successfully, but these errors were encountered:
Hi @apkraven
Thanks for your suggestion. I'd agree option 2 would be the most complete, however I have no idea about the Garmin side of things so that'll leave me with the option1 as it's simple and therefore less prone to fail. It's also the quickest to implement. I should hopefully have some time next week to look at this
Hi @apkraven Thanks for your suggestion. I'd agree option 2 would be the most complete, however I have no idea about the Garmin side of things so that'll leave me with the option1 as it's simple and therefore less prone to fail. It's also the quickest to implement. I should hopefully have some time next week to look at this
Hi, thanks for the perfect working solution. Can you help me finish what I started?
Goal: not just get only MQTT, but also have the ability to upload values to Garmin connect.
Reference: https://github.com/RobertWojtowicz/miscale2garmin has a very similar code with only several changes. We could add this as a feature to your repo.
Two ways I could reach the needed result:
2.1 To configuration file: Add a boolean, SENDTOGARMIN: false (to control whether this will get executed or not)
2.2 To configuration file: Add a string to USERS, GARMINCONNECTPASSWORD: "..." for each user to be available to send to his own account.
2.3 Add a file, which seems to do the raw Garmin export: https://github.com/RobertWojtowicz/miscale2garmin/blob/master/bodycomposition
2.4 After MQTT send, add a code similar to:
Calculate metrics and send to garmin connect
if selected_user is not None and SENDTOGARMIN is true and GARMINCONNECTPASSWORD is not empty:
lib = Xiaomi_Scale_Body_Metrics.bodyMetrics(weight, selected_user.height, selected_user.age, selected_user.sex, int(miimpedance))
bone_percentage = (lib.getBoneMass() / weight) * 100
muscle_percentage = (lib.getMuscleMass() / weight) * 100
message = (path) + '/bodycomposition upload '
message += '--bone ' + "{:.2f}".format(bone_percentage) + ' '
message += '--calories ' + "{:.2f}".format(lib.getBMR()) + ' '
message += '--bmi ' + "{:.2f}".format(lib.getBMI()) + ' '
message += '--email ' + selected_user.email + ' '
message += '--fat ' + "{:.2f}".format(lib.getFatPercentage()) + ' '
message += '--hydration ' + "{:.2f}".format(lib.getWaterPercentage()) + ' '
message += '--metabolic-age ' + "{:.0f}".format(lib.getMetabolicAge()) + ' '
message += '--muscle ' + "{:.2f}".format(muscle_percentage) + ' '
message += '--password ' + selected_user.password + ' '
message += '--physique-rating ' + "{:.2f}".format(lib.getBodyType()) + ' '
message += '--unix-timestamp ' + mitdatetime + ' '
message += '--visceral-fat ' + "{:.2f}".format(lib.getVisceralFat()) + ' '
message += '--weight ' + "{:.2f}".format(weight) + ' '
os.system(message)
print("Processed file: " + (mitdatetime) + ".tlog")
I assume the changes are minimal and I would be glad to do the testing if you would be willing to help :)
Please let me know if it's something that could be done.
The text was updated successfully, but these errors were encountered: