Add Xiaomi Mi Scale to Xiaomi BLE

Feeling silly now! :slight_smile:
Thanks for that, Iā€™ve installed bodymiscale as suggested and itā€™s working perfectly.

Thanks @Ernst!

like @Eoin Iā€™m currently using ESPHome and also in combination wiht the BodyMiscal custom component.

The benefit of using Xiaomi BLE rather than ESPHome is that the scaleā€™s signal will be picked up by any ESPHome BLE device rather than the single ESPHome devices on which Iā€™ve configured it currently using ESPHome.

However Iā€™m wondering whether using Xiaomi BLE I can replicate this functionality I have in ESPHome?
What the below code does:

  • checks whether I have disabled logging the weight or not (variable ā€˜scaleconnectionā€™, which is toggled by scanning an NFC tag that Iā€™ve attached to the scale).
  • Based on the weight identifies whether itā€™s my, my partner or one of the kids and assigns the measurements to the right variables.
  • notifies that a measurement was done (event ā€˜scaleusedā€™) so that my smart speaker can announce the weight change or for example that the measurement wasnā€™t logged because scaleconnection is switched off.
- platform: xiaomi_miscale
    mac_address: '53:FD:19:31:40:60'
    weight:
      name: "Xiaomi Mi Scale Weight"
      id: weight_miscale
      on_value:
        then:
          - lambda: |-
              if (id(scaleconnection).state) {
                if (id(weight_miscale).state >= 76 && id(weight_miscale).state <= 87.00) {
                  return id(weight_john).publish_state(x);}
                else if (id(weight_miscale).state >= 64.00 && id(weight_miscale).state <= 75.99) {
                  return id(weight_jane).publish_state(x);}
                else if (id(weight_miscale).state >= 30.01 && id(weight_miscale).state <= 40.00) {
                  return id(weight_son).publish_state(x);}
                else if (id(weight_miscale).state >= 21.00 && id(weight_miscale).state <= 30.00) {
                  return id(weight_daughter).publish_state(x);};
              }
              else {
              }
    impedance:
      name: "Xiaomi Mi Scale Impedance"
      id: impedance_xiaomi
      on_value:
        then:
          - lambda: |-
              if (id(scaleconnection).state) {
                if (id(weight_miscale).state >= 76 && id(weight_miscale).state <= 87.00) {
                  return id(impedance_john).publish_state(x);}
                else if (id(weight_miscale).state >= 64.00 && id(weight_miscale).state <= 75.99) {
                  return id(impedance_jane).publish_state(x);}
                else if (id(weight_miscale).state >= 30.01 && id(weight_miscale).state <= 40.00) {
                  return id(impedance_son).publish_state(x);}
                else if (id(weight_miscale).state >= 21.00 && id(weight_miscale).state <= 30.00) {
                  return id(impedance_daughter).publish_state(x);}
              }
          - homeassistant.event:
              event: esphome.scaleused

I am using the new integration via a Shelly relay. It works well and can do your first two bullets and mostly the third one as well (I am using AppDaemon for that but it could work with Home Assistant scripts as well).

However, there is an issue with the scaleused event. In particular, when the measurement is exactly the same as before, the sensor does not update and thus the speaker does not announce anything. This is a surprisingly frequent issue.

I think using force_update for the sensor could help with my issue, or the integration itself could emit an event.

1 Like

I was wondering how a relay comes into play for the Xiaomi scale. It took me a while to understand that the Shelly relay also has Bluetooth and can act as a gateway :slight_smile:

Where exactly do you put the logic that I currently do in ESPHome when using the Xiaomi BLE integration.

Iā€™m not sure why but yes I have the same experience as you that it doesnā€™t work when the measurement is identical to the previous one. I donā€™t consider this an important problem so never really tried to solve it.

The Xiaomi BLE integration creates a mass sensor with the last measurement.

I would then make a trigger-based template sensor for each person, watching the mass sensor state and update itself (only) if the new measurement is within that personā€™s weight range.

(I did not actually do this, my current setup is similar but mostly built in AppDaemon.)

1 Like

is there any plan to add impedance to the Xiaomi BLE integration?

I have an impedance sensor created by the Xiaomi BLE integration:

Impedance is only available for the V2 MiScales. Make sure you wait long enough after weighing, impedance is only send after the weight is stabilized.

need some help here. Mi Scale V2 wont show up in BLE Monitor. Is it required to pair the MiScal with the MiScale App first?

Yes, you need the Zepp Life app once for the initial setup of the Mi Scale. After the initial setup you can safely remove the app from your phone.

1 Like

Thanks that worked.

2 more question.

  • do i need to unpair within bluetooth from the Zepp App before removing it?
  • do i need to delete all data from Zepp App before removing it?

Cheers
PX80

No.

No.

After the initial setup of the Mi Scale you can just remove it from your phone or simply donā€™t use it anymore. Zepp Life is just needed for connecting your scale to your bt network.

but it will be fine to delete the account iā€™ve created with Zepp App, right?

Well, I can not answer you this one. I just left it alone after having finished the initial setup. Doesnā€™t hurt me anyway :wink:

How good is the Bluetooth on that MiScale? Seem i have to move it from bathroom to PC Room to get a signal. other devices in that room reports fine. is there a way to increase/enhance the BT Signal as other devices wor well with my RPi4 BLE

For the Mi Scale 2 I am using ESPHome with Bluetooth Proxy here. Works quite well although the scale is in the 2nd floorā€™s bathroom while the HA device itself is far away on the 1st floor, all concrete walls.

think issue could be due to SSD in my RPi4 see Migrated to PI 4, bad range? (USB3 2.4GHz interference) Ā· Issue #430 Ā· custom-components/ble_monitor Ā· GitHub

Any recommendation for a BT Dongle foir RPi4 ?

Does anyone find solutions for the new Xiaomi Scale S400 yet? My old Scale 2 was out of order so I bought a new Xiaomi S400 Scale but unable to add into HA via BLE, ESPhome, Xiaomi BLE. None of these integrations got broadcast from this scale.
Hereā€™s its information

Try to collect some ble data by enabling debugging in the Bluetooth integration and post the logs here. I can try to add it, if I get some BLE data logs.

1 Like

Thank you, and sorry for may late response.
Iā€™ll try but actually I donnā€™t know how to enabling debugging in the Bluetooth integration and getting logs for this.
Iā€™ll try to learn