Passive BLE Monitor integration (Xiaomi Mijia BLE MiBeacon monitor)

@schilea Thanks for the positive feedback! Usually, users write to me only about problems, and the feeling begins to appear that the component works well only for me :smiley: Just kidding )

Can you tell us more about your installation, and how far are the sensors from the host?

@Magalex it is better to draw: pi4 is upstairs, 2m height from the floor on the halway top of the stairs. Sensors are one in the room behind, opposite wall approx 4m, the second one on the room from the right opposite wall, 7 to 8m, while the last one, marked with solid is downstairs, bottom of the stairs an the entrance of living room that is open space. let’s say 4m vertical height and a floor between pi and sensor. There will be another sensor on the room from the left but this is on the way. I have tried to place pi/ node mcu at relative equal distance to the sensors.

2 Likes

@Magalex awesome component, works flawless for me.

Will you PR it into HASS or always have it as a custom?

1 Like

I still know too little about the HA architecture, and the requirements for components that are added to the official repository. I suspect that there is still a lot of work along this path, and already now I have encountered some scarcity of documentation for developers. Therefore, it remains as it is for now…

The custom component has advantages. For example, the ability to quickly fix bugs and quickly implement new sensors thanks to independent component update. It’s easy to organize a public beta test, for example, and more.

@baz123 I forgot to mention the fact that you don’t need to manually introduce the logic of anti-bounce and delays using automations - in HA this is already implemented using the climate platform and the generic_thermostat component (look for min_cycle_duration and hot_tolerance parameters), for which there is also a Lovelace card.

I use this platform in association with Schedy. It does not help. My tolerance for my UFH is 0 hot and cold with a precision of 0.1. Rapid variations of more than 0.1 causes issues.

In these images, I am seeing fluctuations (jitter) of 0.3-0.5 which is not acceptable. My point was, that after I restarted HA, that variation dropped to 0.1 which suggested to me this was an issue with the component.

I’ve not gone back to it to check again.

The component parser is one for all supported sensors. And in the case of LYWSD03, which sends data every 10 minutes, the component transfers the data as is, without applying any additional algorithms to them, therefore, an error is excluded here.

As I said earlier, jitter will be in any case, and you have to fight it. Either delayed response, or the introduction of hysteresis (tolerance), or both.

If there is a need to maintain the temperature with high accuracy, then it seems to me that the LYWSD03MMC sensor is not suitable for these purposes.

I simply run the received data through a couple of filters and that smooths it out and yes delays but that is better than the jitter for my purposes.

Yes, this is also a solution. Can you tell in more detail which components you used for filtering?

Hi Gents! I am a noob why my basic silly questions and hope I am not posting in the wrong forum.
I have tried seaching and scouring the forums but could not find what I was looking for.

Status: I have HA (the erstwhile Hassio) running on a RPI3. All is well. About a month back, I bought 2 x LYWSD03 and that is how learnt of the mitemp_bt. Of course, it did not work back then! I wish to now get the integration going.

Actions: I do not know what hci is - I plan to use built-in BT of the pi (at least as a start). I use the SSH terminal to loginto HA.
image
after this, I turn the scan off.
I installed the stream app in an iPhone. I also have the China registered Mi app with both sensors configured and working well.
So, start the sniffing on Stream and immediately poll the sensor on the mi app.
Even from the detail view on the Stream app, I can not locate a bind key. I tried exporting a 3 minute sniff HAR file (while the temp and hum were nicely updated on the Mi app) and read in it visual code but could not find the bind key.

Guidance please.
Q1. What is hci? is it okay to use btctl as a start? Am i doing it all wrong?Should I alswyats keep scan on?

Thanks in advance.

PS:
Even with this in my config.yaml, all I get as a result is a my BT laptop!

device_tracker:

  • platform: bluetooth_tracker
  • platform: bluetooth_le_tracker

all this discussions are based on rpi3 with bluetooth. I have moved to minipc for HA (that actually has bluetooth, but since HA is in Virtualbox, I believe it would be too much struggle to use it) and I plan to use ESP32 with ESPhome (that I use also for some other sensors and relays) to connect to those modules (I have a few of them). How can this be estabished?

Hello, @amitseth! You can read about hci on wikipedia. In fact, this is your bluetooth module interface, which in your case will be called hci0. If in the future you insert a usb-bt dongle, then there will be two hci interfaces in the system - hci0 and hci1.

For the component to work, nothing else needs to be run (except HA itself). Here is the minimum working configuration (for your LYWSD03MMC):

sensor:
  - platform: mitemp_bt
    encryptors:
      "A4:C1:38:88:BB:4E": "< bind_key1 >"
      "<2nd sensor MAC>": "< bind_key2 >"

Other options are described in the documentation.

The addresses of both sensors you already know how to get - use bluetoothctl. After you receive both addresses, turn off scanning.

It may not have been very clear from the text of our FAQ that traffic should be collected when adding a sensor to the MiHome application (I added an explanation).

Our FAQ also says that the component conflicts with bt-trackers, so bluetooth_tracker and bluetooth_le_tracker should be turned off. In the future, if you still need trackers, the most reliable solution is to use two bt devices (internal one and external usb-dongle).

1 Like

Raspberry Pi is discussed here most often, because, as I understand it, this is the most common platform for Home Assistant. Because of its price, it seems to me. My personal opinion is that this platform is poorly suited for the implementation of good smart home system due to its low reliability and other shortcomings.

Home Assistant works great on other platforms, and there are no barriers to using the component discussed here on other platforms. Personally, I have HA installed on an old mac mini, and I was forced to dust off my raspberry only as part of testing the component in Hassio. The only component requirement for the hardware platform - is the presence of a bt-interface (built-in or external). In the case of Virtualbox, this issue can be resolved using usb passthrough.

ESPHome also uses passive reception of messages, however, the list of sensors supported by this platform is slightly smaller than that of the component discussed here. If this platform is used only to expand the coverage area, then our FAQ describes other ways to solve this problem.

1 Like

I fully understand why the discussion is based on RPI. I also started on it and only recently migrated. I would just need some hints how to use this component.

Meanwhile I realised that my variant of the computer does not have bluetooth so I am looking for other solutions than. My idea was to do like on https://medium.com/@chatupornrungcharoesrichai/use-esp32-to-collect-temperature-and-humidity-from-xiaomi-sensor-via-bluetooth-73362ac74cf6 but with your component so I will get passive data from this sensor

Hi, i get to work my LYWSD03MMC. How can i add my second LYWSD03MMC located in another room with this component? is this correct?

  - platform: mitemp_bt
    rounding: True
    decimals: 2
    period: 60
    log_spikes: False
    use_median: False
    active_scan: False
    hci_interface: 0
    batt_entities: False
    encryptors:
               'A4:C1:38:1D:16:41': '0d1bc96a6-------dd43d4319a452b8'
               'A4:C1:38:0E:88:50': '96aa0e1f6---------692'
    report_unknown: False

Yes, the configuration looks correct. The only thing is that the key must be 32 characters long (both keys length must be the same).

Yes, i know that. keys are corrent. I just hide the entire keys.

Just in case, I want to note that most of the options are not really needed, since the specified values ​​are the default values.
Your configuration might look like this:

  - platform: mitemp_bt
    encryptors:
               'A4:C1:38:1D:16:41': '0d1bc96a6-------dd43d4319a452b8'
               'A4:C1:38:0E:88:50': '96aa0e1f6---------692'
1 Like

Thanks, great component. Keep up good work!

1 Like

Oh, the man himself - @Magalex. I am humbled and truly appreciate your wonderful development as well as taking time out to help me.
Your tips are very useful. I hope to get things to work and report back soon.
Stay safe during these trying times!

1 Like