Integrating Xiaomi Mi Scale

log errors are from your add-on.
i am running hass.os

i tried to find a proper instruction how to add a bt dongle - didn’t find
i tried with a no-name bt dongle 5.0 - didn’t work
tried to use another project - couldn’t match the one serge1peshcoff wrote - cannot run container for hass.os

last hope is either u have some magic trick or to find a documented way to put an esp32 as a bt dongle

Thanks. I have a potential fix that I’m working on, specifically related to RPis and appears to make the BT connection more reliable.
Hopefully I have time to work on it over the next few days.

Hello, you can l integrated with esphome. Here is my adaptation.

Here a custom_components to process the data.

Published 0.1.17

  • Reduced docker image size
  • Fixed config.json startup deprecated option (fixes https://github.com/lolouk44/hassio-addons/issues/32)
  • Added BLUEPY_PASSIVE_SCAN Option to help with some Raspberry Pi devices getting errors like Bluetooth connection error: Failed to execute management command ‘le on’. Set to true if you have this error and let me know if it fixes it pls.

Thank you for fast update, but still the same error appeared after update.
Maybe for the guys that will want add-on is necessary a separate project how to have smooth ble integration.

Meantime, the custom integration of @dckiller51 is working almost fine. Maybe some developer eye can modify the code to not issue some errors, but for now it’s working in this way.

Thanks. the other integration is ESPHome, so completely different setup.
Just one last question: did you set the BLUEPY_PASSIVE_SCAN option to true?
Unfortunately I’m relying on the bluepy library, and it works for me on both a ubuntu server and a Raspbery Pi3, so I’m struggling to see how to fix this since I can’t reproduce.

i will try to test once again with that option to true.
i’m running hass.os in a vm

Published 0.1.18
Changed

  • Restored correct code after accepting a PR based on older code in 0.1.17

and then… Tada !!! Unlimited users now available !
Published 0.2.0
!!! Breaking Changes !!!

  • Allow any amount of users to be configured (removes limit of three) (based on https://github.com/lolouk44/hassio-addons/pull/18)
  • Users need to be added as a list (see config example)
  • All users must now provide a GT and LT value
  • Try not to overlap ranges - if you do it will ony pick the first one that matches
2 Likes

Thanks for this and it works OK :slight_smile:
One BIG request (to tighten Your busy schedule…)- could You please update the standalone version too- so HA users running venv install can also benefit from adding more users.
TIA, JR

Thanks for the kind comments. Unfortunately you can’t define lists / tables in docker compose so a dynamic list of users is not possible :worried:
If someone has another / a better idea please shout

OK, sad :frowning:
BTW I am running this:

Running script directly on your host system (if your platform is not listed/supported):

Note: Python 3.6 or higher is required to run the script manually

    Install python requirements (pip3 install -r requirements.txt)
    Open wrapper.sh and configure your environment variables to suit your setup.
    Add a cron-tab entry to wrapper like so:

@reboot bash /path/to/wrapper.sh

also not possible?
Best, JR

I’m not sure if it’s possible to define an array as an environment variable (initial quick search suggests not)
In any case it’s the same code as the docker container, so it wouldn’t work and I don’t want to create a separate repo / maintain a separate code for this (already doing so for the add on)
I will investigate creating a config file instead of the docker / system environment variables

Screen Shot 02-21-21 at 08.14 PM

I’ve attached the Config and Log files for both Mosquitto Broker and Xiaomi Mi Scale Add-ons.

My Home Assistant is installed on a VM on Windows 10. Can you spot anything wrong in the attached configurations ?

Thank you in advance,

Mimuncu

are your mqtt credentials correct? Your password seems awfully long (and probably should not be shared here)
Have you tried to connect to the broker via a third party app like MQTT Explorer to check you are receiving messages?
Also what happens when you step on the balance? Does the app states it’s publishing anything?

homessistant gui


docker-compose config

homeassistant configuration
homeassistant
mi-scale container log
mi-scale-container-log

I cant to connect.
it’s my configurations above.

Help me, please.
I have the mi scale 2 body composition

Can’t spot anything wrong at the moment.

  1. Have you tried to step on the scale after starting the container?
  2. have you made sure the Xiaomi app is not running?
  3. have you checked that your MQTT broker receives the data? (e.g. via MQTT Explorer)

Does anyone successfully run this addon on raspberry pi 4 with Home Assistant OS?
If I have setting BLUEPY_PASSIVE_SCAN set to TRUE, then I’m getting these errors:

2021-03-17 14:56:51 - Bluetooth connection error: Failed to execute management command 'pasvend'
2021-03-17 14:56:51 - 5+ Bluetooth connection errors. Resetting Bluetooth...
Can't init device hci0: Connection timed out (110)

If I set it to FALSE, then I get these errors:

2021-03-17 15:38:55 - Bluetooth connection error: Failed to execute management command 'scanend' (code: 11, error: Rejected)

My weight is being recorded once in a while though, but not every time I step onto the scale. I’m trying to figure out why sometimes it doesn’t work.

Some information that I managed to gather:

2021-03-17_15-45

found some info online saying that bluetooth device might be blocked, but rfkill command doesn’t work for me so I can’t even check.

Any help would be greatly appreciated, I’m out of ideas :frowning:

Just a thought, is bluetooth on when you go into raspi-config?

I don’t think raspi-config is available in Home Assistant OS.
I restarted my raspberry pi and I found that bluetooth was powered ON on startup, but got powered OFF again after some time

Sorry mate I have zero knowledge of home assistant os. See if you find something anywhere related to Bluetooth and HA OS