Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Garmin connect upload #56

Closed
apkraven opened this issue Dec 29, 2021 · 4 comments
Closed

Garmin connect upload #56

apkraven opened this issue Dec 29, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@apkraven
Copy link

apkraven commented Dec 29, 2021

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:

  1. 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.
  2. 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.

@apkraven apkraven added the enhancement New feature or request label Dec 29, 2021
@lolouk44
Copy link
Owner

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

@lolouk44
Copy link
Owner

Closed via release 0.2.7

@KBD77
Copy link

KBD77 commented Jul 1, 2022

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 Can we use it now?

@lolouk44
Copy link
Owner

lolouk44 commented Jul 1, 2022

@KBD77 Release 0.2.7 exposes the impedance so yes you can use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants