Passive BLE Monitor integration (Xiaomi Mijia BLE MiBeacon monitor)

I will update the FAQ. But to do that, a question for you. Do you use the Mi Home mod now, or did you update afterwards to the official Mi Home?

Why are you sing the Mi app at all? Does it give any advantage for you? I did only install it once to get the data and couldnā€™t uninstall it fast enoughā€¦ :smiley:

Thanks @Magalex. Sorry for taking some time to respond, end of year holidays.

Anyway, Iā€™m not knowledgeable enough to tell you about the quality of the Power Supply and the cables that I have, so I guess the easiest way is to outline my hardware components.

Power supply: https://www.amazon.com/gp/product/B07TYQRXTK/ref=ppx_yo_dt_b_asin_title_o03_s01?ie=UTF8&psc=1

Extension Cord:

I use it for the WYZE hub thingy so I can use it with Wyze Sense and for the ZWAVE dongle

Nortek Zwave Dongle:

RP Case (donā€™t know if this makes much of a difference):

The BT dongle as mentioned before, is connected directly to the PI, without an extension cord

SSD:

SSD Casing:

Below is a picture of my actual setup

  1. Zwave
  2. Wyze
  3. BT Dongle
  4. SSD

At this point my BLE setup has been completely reset, from when it was working, so Iā€™ll try bringing my Xiaomi sensors close to the RP4 to see if the BT detects them.

As for your recommendation for the Ferret Rings, which rings should I use and where on the extension cords should I put them?

Thank you again!

1 Like

@Magalex - I can confirm that once I placed the Xiaomi devices right next to the RP4 all 4 of them were detected and seem to be working as expected!

Put the USB dongle on a long usb cord. Afterwards put every of your three (1,2,3) away from each other and away from the Pi. What youā€™re actually doing is disturbing all your signals far more than you need to. :slight_smile:
The built-in BT is directly next to your BT dongle, interfering with each other.

I used Mi Home mod on android device in order to get an active encr key.
And now Iā€™m using an official Mi Home app on my Iphone in order to get sensors data remotely. (Configuring secure remote access to my HA still in process).

Thanks @paddy0174. So even though I agree with you in principle that the signals from the Zwave, Wyze and BT would interfere, they were working fine before I switched from the SD to the SSD so I donā€™t think thatā€™s truly the culprit. Maybe there was interference but it would have been minimal (I think).

Having said that, I did separate them a bit more and now my setup looks like the image below

  1. RP4
  2. Nortek + Wyze
  3. BT
  4. SSD

Thereā€™s some minor progress, 2 of my 4 sensors are being picked up but the other two not yet.

If the SSD is truly the culprit and causing interference, what would be causing it? The SSD itself, or the cables?

Per @Magalex should I try putting ferrite rings and if so, which ones and where? Or possibly a better power supply?

Thank you all!

This is the biggest clue you can getā€¦ :smiley: If they work nearby, then interference is too high. Simple as that. :smiley: :smiley: :smiley: I wouldnā€™t suspect the SSD alone, imho it is more the sum of all things together. Try to straighten all the extension cords to its max, if necessary stick them on your wall just for a test setup. Iā€™m quite sure, if you experiment with your setup, you will find a working solution. Btw. that is a Sonos speaker, isnā€™t it? Donā€™t they have Wifi and BT built-in? :wink:

You are on the american continent, arenā€™t you? Maybe something inside your wall? We have different building standards here in Germany, so I canā€™t say. But if you have a dry wall behind, maybe there is something behind it, that disturbs your signalsā€¦ :slight_smile:

I had kind of the same problems, before I re-designed my setup. :slight_smile:

Hi. Thank you for this integration. Works well with my LYWSD03MMC with custom firmware.

I have successfully updated from mitemp_bt to ble_monitor. Can I safely delete the mitemp_bt folder in config > custom component folder?

Yes, you can safely delete it.

1 Like

0.9.5 has been released with support for Xiaomi Smart Water Leak Sensor (SJWS01LM)

0.9.6 is currently in beta, with support for CGDK2 Cleargrass temperature and humidity sensors.

For the next release (0.9.7), Iā€™m working on support for the standard ATC advertising format of LYWSD03MMC sensors with custom ATC firmware. This custom firmware is already supported when setting it to Mi-Like advertisement format, but the ATC advertising format supports more accurate measurements and voltage measurements of the battery. To be expected in 0.9.7.

3 Likes

I am using the custom firmware on the LYWSD03MMC and put the display to Fahrenheit in the firmware, I then added it through the UI in Home Assistant and selected Fahrenheit but the numbers that are shown in HA are still in Celsius with an F after them for Fahrenheit. How do I fix it.

Update: I fixed by changing it to C in the UI, but then I had to disable and then enable the entity, it now shows the numbers in Fahrenheit in HA

0.9.6 has been release with support for Cleargrass Qingping Temperature Humidity sensor (CGDK2). Note that this sensor requires an encryption key.

Hi , GREAT integration and well done, itā€™s not easy with limited developer docs in HA.

I have a problem with custom fw and this integration using the LYWSD03MMC sensors when using both the original https://github.com/atc1441/ATC_MiThermometer and the forked https://github.com/pvvx/ATC_MiThermometer

With stock OEM fw, the sensors work perfectly with this integration on latest home assistant as of today and on a Raspberry Pi3B running Raspberry Pi OS (Debian Buster) with kernel 5.4.83 (updated to latest kernel for this OS). BT version if the controller is 4.1. I use the OTA flasher to grab the bind key and set this as the encryption key on your integration (I am using ā€˜discoveryā€™ and no yaml files).

all works fine

I wanted to test with ATC firmware. So I removed all the devices and the integration and stopped HA. Then I flashed ATC fw to a sensor. All went well and I can see the new sensor updated (name is ATCā€¦) and display on sensor LCD is changed. I can also see the sensor on a BT scan using `sudo hcitool lescanā€™ in linux. It shows up. GREAT! So far so good.

When I restart HA, your integration fails to discover the sensor. I waited 20 minutes, nothing. So I reflashed stock fw, restarted HA, and the devices now get discovered. I repeat custom fw flash , again no devices found. Reflash custom fw and they all appear.

Something is wrong with the setup. The following log is when using custom fw but as you can see it does not discover any devices of the LYWSD03MMC

2021-01-17 21:59:50 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: Scanning will be restarted
2021-01-17 21:59:50 DEBUG (Thread-12) [custom_components.ble_monitor] 2642 HCI events processed for previous period.
2021-01-17 21:59:50 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: Run
2021-01-17 21:59:50 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: connected to hci0
2021-01-17 21:59:50 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: start main event_loop
2021-01-17 22:00:51 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 1 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0
2021-01-17 22:00:51 DEBUG (MainThread) [custom_components.ble_monitor.sensor] 1 MiBeacon BLE ADV messages processed for 4 measuring device(s).
2021-01-17 22:00:51 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: main event_loop stopped, finishing
2021-01-17 22:00:51 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: Scanning will be restarted
2021-01-17 22:00:51 DEBUG (Thread-12) [custom_components.ble_monitor] 2721 HCI events processed for previous period.
2021-01-17 22:00:51 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: Run
2021-01-17 22:00:51 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: connected to hci0
2021-01-17 22:00:51 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: start main event_loop
2021-01-17 22:01:51 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 0 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0
2021-01-17 22:01:51 DEBUG (MainThread) [custom_components.ble_monitor.sensor] 0 MiBeacon BLE ADV messages processed for 4 measuring device(s).
2021-01-17 22:01:51 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: main event_loop stopped, finishing
2021-01-17 22:01:51 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: Scanning will be restarted
2021-01-17 22:01:51 DEBUG (Thread-12) [custom_components.ble_monitor] 2571 HCI events processed for previous period.
2021-01-17 22:01:51 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: Run
2021-01-17 22:01:51 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: connected to hci0
2021-01-17 22:01:51 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: start main event_loop
2021-01-17 22:02:52 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 1 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0
2021-01-17 22:02:52 DEBUG (MainThread) [custom_components.ble_monitor.sensor] 1 MiBeacon BLE ADV messages processed for 4 measuring device(s).
2021-01-17 22:02:52 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: main event_loop stopped, finishing
2021-01-17 22:02:52 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: Scanning will be restarted
2021-01-17 22:02:52 DEBUG (Thread-12) [custom_components.ble_monitor] 2600 HCI events processed for previous period.
2021-01-17 22:02:52 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: Run
2021-01-17 22:02:52 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: connected to hci0
2021-01-17 22:02:52 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: start main event_loop
2021-01-17 22:03:53 DEBUG (MainThread) [custom_components.ble_monitor.binary_sensor] 1 MiBeacon BLE ADV messages processed for 0 binary sensor device(s) total. Priority queue = 0
2021-01-17 22:03:53 DEBUG (MainThread) [custom_components.ble_monitor.sensor] 1 MiBeacon BLE ADV messages processed for 4 measuring device(s).
2021-01-17 22:03:53 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: main event_loop stopped, finishing
2021-01-17 22:03:53 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: Scanning will be restarted
2021-01-17 22:03:53 DEBUG (Thread-12) [custom_components.ble_monitor] 2643 HCI events processed for previous period.
2021-01-17 22:03:53 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: Run
2021-01-17 22:03:53 DEBUG (Thread-12) [custom_components.ble_monitor] HCIdump thread: connected to hci0

... repeated ..

Hello,
please, could you someone tell me how can I get encryption key (bing_key) for my CGDK2? I have instaled MiHome, Qingping apps, I can read BLE detail informations, but the key is still secret for me. HomeAssistant shows me only entities but uknown values.
Thank you.

Take a look into the readme:

Did anyone who integrated MCCGQ02HL (the door and window opening sensor) into Home Assistant update the firmware?

According to the Mi Home app, you can set the thresholds of the light sensor with the firmware upgrade, but Iā€™m afraid that it will break the integration to Home Assistant.

SCHOOLBOY ERROR

I did not set the firmware advertising as ā€œMi Likeā€. Default is custom but custom is incompatible with this integration - however we note that the brilliant developer of this integration is looking to support the custom setting in his next release.

I set advertising to custom and rate at 1 minute - all good now.

Work on ATC ā€œcustomā€ advertisement support is added in the latest beta (0.9.8) by me. Iā€™m waiting a bit longer with the final release, to see that there are no major issues. If you want to try, install the latest beta via HACS. My advise is not to use advertisement type ā€œallā€, as it will decrease accuracy and will not always display the voltage sensor (depends on whether it receives ā€œmi-likeā€ or ā€œATC1441/customā€ message first).

Still canā€™t get it working, copied custom_components into config folder on server, but no BLE devices discovered and I do not see any new integrations to appear?

Oh I had to refresh, all OK! Thanks for integration!