Add support for Xiaomi Body Composition Scale S400 #1297
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
Thank you for maintaining openScale. I just bought the Xiaomi Body Composition Scale S400 and I noticed openScale didn't support it, so here we are.
I didn't reverse the bluetooth protocol myself, I leveraged the work done in this repo, so that sped things up.
This scale uses encryption in its bluetooth protocol, so the BLE key must be extracted. Here is how:
1. Initial Scale Setup (if not done)
2. Extract Tokens Using Xiaomi Cloud Tokens Extractor
When prompted:
defor Germany,usfor USA,cnfor China)3. Find Your Scale's Information
The extractor will output a list of all your Xiaomi devices. Look for your scale:
Save these two values:
XX:XX:XX:XX:XX:XX)4. Kill the Xiaomi Home App
Kill the app or uninstall it.
Once you have the key, this is pretty straightforward.
This is a measurement done with the Xiaomi Home App:
This is a measurement done with openScale (there is a difference because I did the measurement in the Xiaomi Home app the day after, while making this PR, to prove that it works):

Here are a few other screenshots:
To be clear: I built the app locally in debug mode, sideloaded it onto my phone and performed a real measurement.
I had to add a little bit of UI to add the BLE bind key in the setting. I couldn't find an existing example in openScale where this was done already, please let me know if I missed it.
Disclaimer: I did use AI to write most of the code. However I reviewed the code to the best of my abilities and I carefully tested the app. I compared all the metrics one by one with the official app to make sure that the values make sense in openScale.