Skip to content

[New Sensor]: Add Xiaomi Scale S400 (Model MJTZC01YM) #1446

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

Open
Xuantam91 opened this issue Mar 13, 2025 · 20 comments · May be fixed by #1453
Open

[New Sensor]: Add Xiaomi Scale S400 (Model MJTZC01YM) #1446

Xuantam91 opened this issue Mar 13, 2025 · 20 comments · May be fixed by #1453
Assignees
Labels
new sensor Request for a new sensor

Comments

@Xuantam91
Copy link

Sensor Description

Xiaomi Scale S400 weight and Impedance sensor

Additional information

I have Xiaomi Scale S400 (Model MJTZC01YM), I try to add to home assistant but it not support.
Pls help

BLE advertisements

@Xuantam91 Xuantam91 added the new sensor Request for a new sensor label Mar 13, 2025
@Ernst79
Copy link
Collaborator

Ernst79 commented Mar 29, 2025

I will need the BLE advertisements to be able to add this device. Please follow the instructions in the documentation to get this.

@RobertWojtowicz
Copy link

RobertWojtowicz commented Apr 13, 2025

Hi, @Xuantam91 @Ernst79,

Something may have been able to move forward?

I'll add that the problem is that BLE communication is encrypted, and from the projects I know of, the data only manages to be acquired through Xiaomi gateway:
RobertWojtowicz/export2garmin#54

BR,
Robert

@Ernst79
Copy link
Collaborator

Ernst79 commented Apr 13, 2025

Yes there is some development. We are (actually, @zry98 is) currently adding it to the official BLE integration.

Related PRs
Xiaomi-ble: Bluetooth-Devices/xiaomi-ble#163
Home assistant: home-assistant/core#142705 (comment)

We can copy that to BLE monitor

@RobertWojtowicz
Copy link

@Ernst79

Thanks for such good news, I understand you mean this solution?: https://github.com/Bluetooth-Devices/xiaomi-ble

How to use (outside of HA) I would like to attach to my integration (sending downloaded and calculated data to Garmin)

BR,
Robert

@Ernst79
Copy link
Collaborator

Ernst79 commented Apr 13, 2025

Yes, that is the parser that is used by HA. I don’t know what you mean with “attach it to my integration”. Which integration?

@RobertWojtowicz
Copy link

RobertWojtowicz commented Apr 13, 2025

Hi @Ernst79

I created a solution for importing data from old Mi Body Composition Scale 2 into Garmin Connect: https://github.com/RobertWojtowicz/export2garmin

I would like to add a new Xiaomi S400 to this integration.

BR,
Robert

@Ernst79 Ernst79 linked a pull request Apr 13, 2025 that will close this issue
@Ernst79
Copy link
Collaborator

Ernst79 commented Apr 13, 2025

Added the scale in 13.2.0-beta for testing. Let me know if it works

@zry98
Copy link

zry98 commented Apr 13, 2025

@RobertWojtowicz Hi, unlike the Mi Scale V2, the S400's advertised metrics data is encrypted with a unique bind key. With decryption implemented, the actual data can be easily parsed similarly. I guess it would be better to just import ble_monitor and let its parser do all the job.

@Xuantam91
Copy link
Author

Added the scale in 13.2.0-beta for testing. Let me know if it works

Appreciate your help, I updated 13.2.0 beta, however my Scale S400 is still not added to BLE Monitor intergration. Can you help to guide me on how to make it works. Sorry, I'm stupid at IT code.

@mukaschultze
Copy link

13.2.0-beta not working here too. Only relevant log I could find was Advertisement doesn't contain payload, adv: 0e1695fe1059d53b005e3d47934684

@zry98
Copy link

zry98 commented Apr 14, 2025

13.2.0-beta not working here too. Only relevant log I could find was Advertisement doesn't contain payload, adv: 0e1695fe1059d53b005e3d47934684

This data doesn't look like anything I've encountered, are you sure it's from a S400? They usually send two types of adv:

  1. one regularly with status, model (0x3BD5), MAC addr. Format: 10 59 D53B [1-byte packet ID] [6-byte reversed MAC].
  2. another one with metrics data, which is useful. Format: 48 59 D53B [1-byte packet ID] [12-byte encrypted data] [3-byte counter] [4-byte AES-CCM tag]. It's sent out only after measurement (when the display is showing weight / body fat ratio / heart rate).

@zry98
Copy link

zry98 commented Apr 14, 2025

Added the scale in 13.2.0-beta for testing. Let me know if it works

Appreciate your help, I updated 13.2.0 beta, however my Scale S400 is still not added to BLE Monitor intergration. Can you help to guide me on how to make it works. Sorry, I'm stupid at IT code.

Have you tried the Xiaomi BLE component? I can't test with ble_monitor right now as I only have an ESPHome BLE proxy.

@mukaschultze
Copy link

This data doesn't look like anything I've encountered, are you sure it's from a S400?

@zry98 Yes, it's from a S400 MJTZC01YM.

  1. one regularly with status, model (0x3BD5), MAC addr. Format: 10 59 D53B [1-byte packet ID] [6-byte reversed MAC].

The ADV from my log does contain 10 59 d53b 00 5e3d47934684 (mac address is correct) which seems like the expected format, but it is padded with some other unknown bytes 0e1695fe

@zry98
Copy link

zry98 commented Apr 14, 2025

which seems like the expected format

@mukaschultze Any other packet after a measurement?

but it is padded with some other unknown bytes 0e1695fe

It seems to be containing the 16-bit service UUID 0xfe95, no idea on the 0x160e part though.

@Xuantam91
Copy link
Author

Added the scale in 13.2.0-beta for testing. Let me know if it works

Appreciate your help, I updated 13.2.0 beta, however my Scale S400 is still not added to BLE Monitor intergration. Can you help to guide me on how to make it works. Sorry, I'm stupid at IT code.

Have you tried the Xiaomi BLE component? I can't test with ble_monitor right now as I only have an ESPHome BLE proxy.

I am using Xiaomi BLE also, but my S400 hasn't been added, only my old scale V2 is added. Screenshot_20250415_071256_Home Assistant.jpg

@mukaschultze
Copy link

So, I was fiddling around with the scale and couldn't get any advertisement other than the one I pasted above. So I decided to test Xiaomi BLE integration, and as soon as I added it the scale started to advertise more data and this integration created new sensors.

The sensors don't have any value, I guess it's somewhat caused by the encryption:

Image

Here's some examples of the new ADV:

  • 1b1695fe4859d53b08bc37a22fa9cda5e1f46a7174040000e16950ff
  • 1b1695fe4859d53b072071f86385d5ec0c56213983040000fa2b096a

@Ernst79
Copy link
Collaborator

Ernst79 commented Apr 15, 2025

Some devices need to be added to MiHome first, before its starts to send useful data. Next step is getting the encryption key, and add that to the ble monitor settings. You can find the encryption key with one of the methods explained in the FAQ https://custom-components.github.io/ble_monitor/faq#how-to-get-the-mibeacon-v4v5-encryption-key

@codigospostales
Copy link

Like @mukaschultze I have got the scale recognized but unknown data.
I have put the BLE KEY obtained from the Token_extractor program, but it still give "unknown" to all parameters.

@allhq
Copy link

allhq commented Apr 25, 2025

Unfortunately, it doesn't work for me either. It finds the device but all sensors are unkown

@andreafuregon
Copy link

I've got the same problem.
I've recently update also to 2025.5.0, but i'm unable to make my S400 working. I've got the MAC address, and also the BLE KEY, but sometimes it find the device with all sensor uknown, sometimes is completly unreachable.
I miss my old Mi Scale 2 :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new sensor Request for a new sensor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants