Passive BLE Monitor integration (Xiaomi Mijia BLE MiBeacon monitor)

Hello! Tell me more about your installation. Is it HA core with python venv?
First, check if the python has access rights to the interface, as indicated in paragraph 1 of the installation manual. It is important to make sure that the rights are granted to the exact interpreter that launches HA (more details are in the FAQ).

Thank you for the prompt response!
I am running Home Assistant 0.110.2 via venv. The venv python3 interpreter does have the rights mentioned in the documentation. It is python 3.8.0.

[email protected]:~$ source pyenv-activate.sh 
[email protected]:~$ getcap `readlink -f \`which python3\``
/home/homeassistant/.pyenv/shims/python3 = cap_net_admin,cap_net_raw+eip

Hm. I propose to do the following:

  • stop HA;
  • run sudo btmon on the command line;
  • start HA;
  • wait for the HA to start fully and stop btmon with CTRL+C;
  • show the output of btmon.

And in order to make sure that we checked the rights of the necessary binary, I suggest running this command:
ps -auxww | grep hass

Thank you, Alex. You are a star!

The ps command showed that a different interpreter was being invoked so I gave it the right permissions and all is well.

Finished. Parsed: 2252 hci events, 1 xiaomi devices.

Apologies for the inconvenience.

1 Like

Finally got my LYWSD03MMC sensors (square ones with encryption key).
They can be swapped between Celsius/Fahrenheit on the display from the app!

Procedure I followed:
First, you MUST install HACS “Xiaomi passive BLE monitor sensor platform” to be able to read LYWSD03MMC sensor(s).
The default/built-in one will currently not work with this sensor. After installing, reboot your HA!

Second, prep the Stream-app on your iOS device:
Open Stream -> HTTPS Sniffing -> CA Install. Then you will be directed to browser to download a VPN profile.
Go to General -> Profile -> Stream Generated CA… -> Install the VPN profile.

After installing VPN profile:
Open Stream -> HTTPS Sniffing -> hit trust CA in settings.
General -> About -> Certificate Trust Settings -> tick green on Stream Generated CA…

Third, make sure you are logged in to MiHome (ensure it is logged-out of other devices and region chosen is mainland China) and open Stream.
Then go to Stream-app and hit “Sniff now”, and immediately go to MiHome, pull the plastic-tab to activate sensor, and add the LYWSD03MMC sensor.
Follow the wizard. Wait for the app to read Temperature and Humidity. (Optionally you can get the MAC-address here. Under the sensor -> settings (3 dots in upper right corner) -> “About”. This is also where you can swap between displaying Celsius/Fahrenheit.
Go back to Stream-app and click “Stop Sniffing“.

Now in stream-app go to sniff history and search for the keyword “bltbind”.
You will see a file “POST https://api.io.mi.com/app/device/bltbind”
(If you don’t see that file, go back to step 2 to check whether the CA was trusted or not.)
Click on that file -> Request -> “Preview Form” at bottom, then at the top hit -> Format -> Decode -> now you look for: find “bind_key”, “value”:
After finding the bind_key, then add it to your “- platform: mitemp_bt” Configuration.yaml together with the MAC-address.
The MAC-address can be found in MiHome under the sensor and settings (3 dots in upper right corner), and “About” if you did not get it earlier. You can change between Celsius and Fahrenheit for the display here also.
Repeat this step until all sensors are added.

Fourth, when done adding all sensors, power-off HA, then restart it.
Once you HA is fully back online, go to Configuration -> Entities -> search for “mitemp_bt” and you will see the 2 sensors for each thermostat (one for temp, one for humidity). Be patient, it can take time (less than 10 minutes) for HA to detect them.

LYWSD03MMC broadcasts temperature and humidity once about every 10 minutes and battery level once an hour.

If you get impatient, you can look for the from the terminal:
[email protected]:~# bluetoothctl
Agent registered
[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:07:AA:AA Discovering: yes
[NEW] Device A4:C1:38:AF:BB:BB LYWSD03MMC
[NEW] Device A4:C1:38:42:CC:CC LYWSD03MMC
[NEW] Device A4:C1:38:42:DD:DD LYWSD03MMC
[NEW] Device A4:C1:38:F1:EE:EE LYWSD03MMC
[NEW] Device A4:C1:38:38:FF:FF LYWSD03MMC
[NEW] Device A4:C1:38:4D:11:11 LYWSD03MMC
[bluetooth]# scan off
Discovery stopped
[bluetooth]# exit
[email protected]:~#

Added class 1 Bluetooth dongle for better reception:
TRENDnet Low Energy Micro Bluetooth 4.0 Class 1 USB 2.0, TBW-106UB
Distance: up to 100Meters/330 Feet.
https://www.amazon.com/gp/product/B002AQSTXM/

Battery indicator will show at the bottom if you click on the sensor.

My config:

sensor:
  - platform: mitemp_bt
    rounding: True
    decimals: 1
    active_scan: False
    hci_interface:
                  - 0
                  - 1
    encryptors:
               'A4:C1:38:AF:BB:BB': '17CD89A41B9FB86CF760968F1C7C9B0D'
               'A4:C1:38:42:CC:CC': '7426CA29015D144F489705CBC625C1C4'
               'A4:C1:38:42:DD:DD': '7AB69F8D733EECAB92337D209ACD2B9E'
               'A4:C1:38:F1:EE:EE': '2DC3683236481DAA7DA2B2FEE4BFD893'
               'A4:C1:38:38:FF:FF': 'C9553E560EE6C36497A864D5E31F085C'
               'A4:C1:38:4D:AA:AA': 'B2219D1E99985CC5BE2C3EDDE8D377C0'
3 Likes

Can’t find bitbind

Yes it is, under integrations. It is called
Xiaomi passive BLE monitor sensor platform
in HACS.

OK got it installed struggling with getting key using stream app

Is this a statement or a question?

need help getting bind_key I have vpn installed but not seeing the POST https… file

All links to the guidelines for obtaining a key using Stream.app are collected in our FAQ.

It is difficult to add something to the already described:

One:

Two:

I think the problem might be that my sensors are already paired with Mi Home, can you only get the key during pairing process?

Yes, the point is precisely that you need to capture pairing process.
If the sensors are already paired, then you need to do it again (remove from MiHome and add again).

OK I removed and repaired and captured the data but still no bitbind is found?

I did this before and it worked, unfortunately I lost all the data on my sd card and had to redo my whole HA installation got everything working accept my sensors. Could Xiaomi have changed something. I am seeing https stuff in the sniff history just not the one with bitbind

Do you search exactly by bitbind? You must search by bltbind. Small L instead of i.

That helps alot I got the file now I need something to read it notepad ++ shows all the html characters

Hmm getting invalid option for batt_entities and rounding from config checker?

According to the latest info IN HACS these are valid options
Acting like its is still seeing the built-in mitemp_bt
Never mind apparently I forgot to restart after install HACS
All is Good