Giter Site home page Giter Site logo

lswiderski / mi-scale-exporter Goto Github PK

View Code? Open in Web Editor NEW
120.0 14.0 10.0 2.41 MB

Mobile App to export data from Mi Body Composition Scale and upload it to Garmin Connect Cloud

License: Apache License 2.0

C# 100.00%
xiaomi garmin garmin-connect garmin-api miscale xiaomi-smart-home xamarin-forms xiaomi-scale android csharp maui maui-app xamarin

mi-scale-exporter's Introduction

mi-scale-exporter

Mobile App to export data from Mi Body Composition Scale (works with Mi Scale too) and upload it to Garmin Connect Cloud. It also allows you to upload manually entered body composition data to the Garmin cloud.

Tested on Oneplus 5T (Android 10) and Mi Body Composition Scale (XMTZC02HM)

Download

Google Play MiScale Exporter

iOS/iPadOS version

Check out this web project: https://github.com/lswiderski/WebBodyComposition

Instruction

  • Stand on your scale. Measure yourself. Complete the user form data, Scale Bluetooth address and get data from the scale. Mi Body Composition Scale is active up to 15 min after the measurement. (Bluetooth address can be found in Zepp Life > Profile > My devices > Mi Body Composition Scale > Bluetooth address (hold to copy)).

  • If your scale supports "Weigh small object" - turn it off

  • Then you can review your data and upload it to Garmin Cloud. If you do not have Mi scale and just want to manually insert the data, you can so.

  • You can save the Garmin password in this App but you don't have to. Passwords Managers like KeePass2 works well too. If you do not provide a password in the settings, you will be asked for it each time before sending. No password will be saved in app.

  • This app support 2FA/MFA codes (since v2.1.0)

  • This App pass your data, email and password directly to Garmin Connect Cloud or you can change it to proxy API server and then it sends to Garmin Cloud.

  • The Proxy API does not store or log anything, it's just a middleware between this App and Garmin services.

  • Proxy API repository: https://github.com/lswiderski/yet-another-garmin-connect-client

  • If you afraid of your data, you can host your own API server. Just change the server address in Settings. For now you can use default one: https://frog01-20364.wykr.es

Diagram of the flow with Web Proxy

sequenceDiagram
    participant Mobile App
    participant Mi Body Composition Scale
    participant API Endpoint Proxy
    participant Garmin Cloud
    Mobile App->>Mi Body Composition Scale: Connect and get data
    Mi Body Composition Scale-->>Mobile App: Weight and Impedance data
    loop
        Mobile App->>Mobile App: Calculate Body Composition
    end
    Mobile App->>API Endpoint Proxy: Body Composition data
    API Endpoint Proxy->>Garmin Cloud: Body Composition data
    Garmin Cloud-->>API Endpoint Proxy: Result
    API Endpoint Proxy-->>Mobile App: Result

API Endpoint used in the app (source)

https://frog01-20364.wykr.es

Diagram of the flow with direct send to Garmin Cloud

sequenceDiagram
    participant Mobile App
    participant Mi Body Composition Scale
    participant Garmin Cloud
    Mobile App->>Mi Body Composition Scale: Connect and get data
    Mi Body Composition Scale-->>Mobile App: Weight and Impedance data
    loop
        Mobile App->>Mobile App: Calculate Body Composition
    end
    Mobile App->>Garmin Cloud: Body Composition data
    Garmin Cloud-->>Mobile App: Result

Stack

  • MAUI & .NET 7 (C#)
  • Autofac
  • Plugin.BLE - To receive data via Bluetooth from Mi scale
  • Xamarin.Essentials
  • API Backend in C# (YAGCC project)

Images

  • Xiaomi settings (Bluetooth adress - Zepp Life)

xiaomi settings

  • required user data

required user data

  • settings

settings

  • measure

measure

  • Calculated body composition

calculated body composition

  • results in Garmin Cloud

garmin result

Inspiration

If you like my work, you can buy me a coffee

Buy Me A Coffee

mi-scale-exporter's People

Contributors

lswiderski avatar neo2shyalien avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mi-scale-exporter's Issues

Zepp Life required after Bluetooth address

Hi, I just got notified of this app and I'm very happy with it already.

One question: Is Zepp Life still required for this app to work if you have the Bluetooth address copied from Zepp Life?

Feedback / Enhancement ideas

Hey Łukasz,

I've been using mi-scale-exporter for a few weeks now and I wanted to give you some quick feedback, as well as some ideas for potential enhancements since my use case is probably a bit different from most people's (ie. I am not using a Mi scale).

First of, mi-scale-exporter works great for me. No bugs, no crashes, it just works flawlessly.

I have been keeping notes of the little things you only notice while actively using something these past few weeks. Perhaps, some of the feedback is useful. In any case, thanks again for making this app.

MFA
MFA works really well now. I only have a couple of suggestions for making it even better:

  1. Since Garmin MFA codes are numeric, maybe it's possible to default to a numeric keypad as well (therefore making it easier to enter the MFA code).
  2. Some apps offer to input the MFA code automatically for you (ie. autofill). As I understand it, this requires an additional permission. It's probably not worth it to implement this, unless it's no fuzz.
  3. (Google Messages offers an option to copy MFA codes to the clipboard from the notification bar. This works for Paypal MFA, for instance but it does not work for Garmin codes - at least not for me. I suspect this is something Garmin would have to address though. Just thought I'd mention it for the sake of completeness.)

Usability

  1. As I mentioned, I don't have a Mi Scale and I use mi-scale-exporter to manually enter the values. And that works great. Perhaps it would be possible to have the app open on the screen that was last used which, for me, would always be "Garmin Form".
  2. Now we're getting into nit-pick territory: my scale doesn't display some information the mi scale apparently does (like "body age"). Maybe it would be possible to a preference dialogue for selecting which data fields are displayed in the UI. I realize, at that point, we're kind of pivoting away from the original purpose of the app (making the Mi Scale usable with Garmin) to more of a generic approach (making any scale usable with Garmin) though.
  3. On the help screen, it still says that MFA isn't supported which is no longer true (as it works great).

Thanks!

Bluetooth

What should I do with this error "Permission to use location (bluetooth) is required to scan"?

Extend support for other popular scales with body composition

Could you add support for other popular scales with similar capabilities?

Withings Body+/Body Cardio
Tanita RD-901
Eufy Smart Scale C1
Fitbit Aria Air
Huawei Scale 3/3 Pro

These have very positive reviews on the internet, close functionality and no native integration with Garmin Connect.
You can find desc and recommendations on Reddit.

This app could become a universal gateway to Garmin Connect if broader scale support is added.

problem z odczytem danych z wagi Mi Smart Scale 2

Witam,

Napotkałem na problem z połączeniem i odczytaniem wartości z wagi xiaomi scale 2.
Pojawia się błąd o treści: "data must by at least 13 bytes long".
Z góry dzięki za podpowiedzi jak to ogarnąć lub naprawę tego buga.

Pozdrawiam,
Marcin.
412640072_1104581147249462_2805604926111556495_n
412478551_1368814057340666_5924825536137112265_n

Getting a flur exception error on upload

Hi,
I changed my phone and a new Garmin account. I'd set up 2fa with Garmin and was getting an error.

Then read the documentation and turned 2fa off, but still getting an upload error message which says:

Failed to upload activity to Garmin. Flur exception.

Is there something I'm doing wrong?

Error code 502

Thanks for your work. In the past app work great. I don't use for some time and now I see error 502 when I like to upload to Garmin connect. I retipe pass but same error. My phone is galaxy S21. Thanks

Crash when starting the first scale "get values"

Device: Xiaomi Note 4X
Android version: 7.0 (latest for this smartphone) / MiUI 9.0
Scale properly connected to the Zepp life app.

How to produce the issue: start to fill the age, height, scale address... then click on the "get values from mi scale" button.

What happens: the app immediatly crashes with the following error:

android.runtime.JavaProxyThrowable: System.FormatException: Input string was not in a correct format.
  at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <862eac71fdb24d8a944879927b29f0c0>:0 
  at System.Number.ParseDouble (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x0007d] in <862eac71fdb24d8a944879927b29f0c0>:0 
  at System.Double.Parse (System.String s) [0x0001a] in <862eac71fdb24d8a944879927b29f0c0>:0 
  at MiScaleExporter.ViewModels.ScaleViewModel.OnScan () [0x0004f] in <ed6ca7ffd07c4c57acc3b8941b348ed6>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in <862eac71fdb24d8a944879927b29f0c0>:0 
  at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <eedaa2491856441381e221d6410352cc>:0 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <eedaa2491856441381e221d6410352cc>:0 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <eedaa2491856441381e221d6410352cc>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.118(intptr,intptr)
	at mono.java.lang.RunnableImplementor.n_run(Native Method)
	at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
	at android.os.Handler.handleCallback(Handler.java)
	at android.os.Handler.dispatchMessage(Handler.java)
	at android.os.Looper.loop(Looper.java)
	at android.app.ActivityThread.main(ActivityThread.java)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)

The error happens every time
All the required fields are populated with correct values (integer for age and height...)

Can’t upload data

Yello

After last update syncing no more working.
It gives error like at the screenshot.
A0E852D1-C549-4532-9EF6-C63216014109

Can't input decimal numbers manually

I wanted to fill a form manually. I can't input decimal numbers with a "," as a decimal separator. The Google keyboard enables only to use dot "." and the form require "," The result is I can't send decimal numbers to Garmin connect portal.

The solution is to accept , as well . as separator and change it to correct form internally before sending to Garmin.

Android 12, CS language settings, Google keyboard.

Flur exception

When uploading I'm getting a Flur Exception. Any idea on what might cause this?

Body Composition Scale 2 Crash

Hello
Thanks for sharing your project.
Mi scale installed OK
Opening
Get values from MI scale
Scanning ..... and crash.

Galaxy s9+
Android 10
Thanks

"age_label" string in Metabolic age column

There is probably some issue in fields parsing and app is sending something that looks like column header along with data.

image

Unless it's some kind of issue on garmin webpage? Can you tell ?

Support for s400

Tried using app with new s400 scale Any chance of extending app to support the new version?

Missing cookie SESSONID

Hi, I have been using MiScale Exporter on Android for a while now, without any issues, however recently, whenever I am trying to upload data to Garmin, I get a "Missing cookie SESSIONID" message and the upload fails.
Is this a known issue? Can you pls let me know if you need any more specific info?
Thanks!

Feature Request: Ability to enter muscle mass as a percentage

First of all, many thanks for making and publishing this. It is much appreciated. :)

I have a body composition scale made by Omron and I use mi-scale-exporter to manually enter the results and push them to the Garmin cloud. I had to disable MFA in order to make it function, but now it works absolutely flawlessly.

This probably isn't exactly the use case you envisioned so I hope it's okay for me to request a feature. My scale outputs body fat and muscle mass as a percentage, as opposed to an absolute value (ie. lbs or kg).

Body fat is already exposed as a percentage in the UI. If it's not too much trouble, would be possible to give us an option to enter muscle mass as a percentage, as well?

Many thanks in advance.

Mi Smart Scale 2

Screenshot_2022-04-15-09-14-18-11_e06dc87044f093fb02b07ac9aeb87c26
Screenshot_2022-04-15-09-14-14-44_e06dc87044f093fb02b07ac9aeb87c26

Tested using Mi Smart Scale 2 on Oppo Reno 5 runnin Android 12. Had to manually set permissions of app in settings, else it would crash after asking location perms.

Gave error in screenshots when I finally got it to pull data off the scale.

Removing dependency on the webapi - Feature request

Hi, I was wondering whether you have ever thought about removing the dependency on the webapi and make this app "self-contained".

There is a project garmin-connect-client that is a C# web client to interact with garmin connect. It works, though I will need to submit a pull request as it has some errors (due to changes to the GarminAPI) but I tested it and it works.

For the generation of the FIT file I can add the necessary code to the services to create the appropriate Fit file with the appropriate data to be uploaded (e.g. via a pull request). The only issue is that I have no experience on Xamarin Forms and I would not able to really test if this really works.

Visceral fat value is rounded to integer

The reading of visceral fat measurement is rounded to integer instead of left in decimal number format.

Eg. Mi scale exporter reads value 12 %,
in openScale app I see value 11,52 % for the same bodymetric measurement.

All other values in Mi scale exporter are in decimal format.

No longer syncing with Garmin (with 2FA enabled)

Since the introduction of ECG on some Garmin watches, they have made two factor authentication over email mandatory so it can no longer be disabled. This seems to be causing issues with syncing.

When I attempt to sync scale data I get an error about missing cookies but I see that the attempt is triggering a TFA code to be sent to my email. I just have no way to input that code into the app and continue syncing the data.

Wrong data from scale

Hello and thank you for your work!

I am trying to use this app with my scale Mi Body Composition Scale 2 (XMTZC05HM) and Redmi Note 11 Pro 5G with Android 11. But I am getting wrong (not some as in my Zepp Life) data. I am using 1.7 release.. new alpha version was crashing before I get any data from scale. Is there any way how can I figure out what's going on without installing Xamarin and other stuff to debug it on my side?

In Zepp Life:
Weight: 67,95
BMI: 22,1
Body Fat: 17,7
Muscle Mass: 53,11
Water: 56,5
Bone mass: 2,85
Visceral fat: 8
Body age: 23
Protein: 21,7
Basal: 1477

In your app:
Weight: 67,95
BMI: 22,4
Body Fat: 18,1
Muscle Mass: 52,81
Water: 56,2
Bone mass: 2,83
Visceral fat: 9
Body age: 24
Protein: 21,5
Basal: 1478

1663489135855

What is the proxy needed for?

Hi, this is not a problem with the app, but rather I don't understand why would anyone need the proxy, when it works (and it does work perfectly, I tried it) without the proxy when it reports straight to the garmin api?

UI improvement

Not very important, but I think the UI could be greatly improved by moving all the parameters of the "scan" page to something more like a profile page, or why not in the main parameters.
the gender, height, login, pass.... are not supposed to change between measures, so why put them here? I know there is a "bypass" option, but is makes the app more confusing.

Also maybe replace the "age" parameter with a date of birth (and then generate the age), so it never has to be changed.

Data could not be obtained

Hi

I installed your app, got the scale (mi 2) address in Zeep life (where the scale is properly connected), and put all the required information on the first page (age, height, sex, address, scale type...).
When I submit, mi-scale-exporter scans, scans, and never find the scale.
I tried before weighting myself, during, after with scale screen on, after with scale screen off, no changes, it never seems to be able to connect to the scale.

The error message is:
Problem
Dada could not be obtained. try again
(twice)

Samsung S20+ Android 12

App crashed

I can't upload anymore. The app crashes after the weight is taken over and stops weighing

Incorect resolution

After the last two updates, I have problems uploading data to garmin, because after weighing, the data appears very large and it is not possible to see the whole screen, nor is it possible to scroll the window up. The data upload button is thus only visible at the very bottom and is very difficult to press (see screenshot).

I have a Realme GT2 phone (RMX3311) loaded with android 13 and the latest version of MiScale Exporter.

Otherwise the app works great!
Screenshot_2023-11-06-04-48-15-75_e06dc87044f093fb02b07ac9aeb87c26

App cannot get data from my scale XMTZC05HM

I'm trying to get data from my mi body composition 2 but with no luck. After tinkering with settings the only thing I get is:

2022-09-22 08:25:38.8417|INFO|E:\Projects\mi-scale-exporter\src\MiScaleExporter\App.xaml.cs|received data but it is unstable, or wrong scale type is selected
27; 24; 2; 132; 230; 7; 9; 22; 8; 22; 16; 0; 0; 64; 1

Failed to connect

Hi,
I have this ssue during the upload to the cloud :
Failed to connect to frog01-20346.wykr.es/65.108.10.92:443 from my android device.

Body fat is 2% higher

Hi, thanks for the app, it generally works really well 🤗 Just one thing works weird for me. In the app my body fat is usually about 28% however in zepp life (Xiaomi app) it's 26%. Initially I thought that zepp app is wrong but seems not because professional readings gave me ~26% as well. My partner is using the same scales and this app as well, for him body fat % is approximately the same in both apps.
Not sure why I'm causing a bug :(

Zepp app data:

Weight 53.80
Muscle 37.19kg
BMI 20.7
Body fat 26.6%
Water 50.4%
Protein 18.8%
Visceral fat 3
Bone mass 2.31 kg

Data transfered to Garmin:

Weight 53.5 kg
BMI 20.6
Body Fat 28.4%
Skeletal Muscle Mass 36.0 kg
Bone Mass 2.3 kg
Body Water 49.1%

If you need more data, I'll be happy to provide anything you need.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.