Passive BLE Monitor integration (Xiaomi Mijia BLE MiBeacon monitor)

You can create a template sensor that does that for you.

@Magalex question about window/door sensors. After restarting the Home Assistant, the sensor state is in an undefined value until its state is changed (for example, the window is closed). Is it possible to solve this problem? Thanks!

The sensor state is set to unknown because it is true :slight_smile: This is how this sensor works. It sends data about its status only either when it changes or when the battery is reinserted. It’s sad, of course.

If you look at the documentation for the current beta version, there is an option restore_state. It is disabled by default, because if you enable it and the status of the sensor changes during the HA restart, then you either will not know about the status change during the restart, or the status of the sensor in HA will not match the real one. It might be not safe. If you are building automation based on this sensor, then think about events, not states, if this possible in your case.

Thanks! I thought that the sensor is initializing the transfer of its state. I absolutely agree that it is better to manually initialize the sensor than to get a false state.

0.8.4 has been released

Changes in 0.8.4 [BREAKING CHANGES]

  • [BREAKING CHANGE] The component now creates binary_sensor entities for MCCQ02HL and WX08ZM sensors, which means that the binary sensor states (e.g. open/closed) now work. After the update, new entities starting with binary_sensor will be created for all your binary sensors. You can remove the old entities starting with sensor, which are no longer used. Also update your lovelace configuration.
  • Added experimental support for YM-K1501 (Xiaomi Mijia Smart Kettle)
  • Minor fixes and improvements
1 Like

Development is going fast. We have released a new 0.9.0-beta which adds support for configuration in the UI. No need to use YAML anymore. Big thanks to @koying who made this possible!

Still want to use YAML? No worries, YAML configuration isn’t changed.

1 Like

Hi, I have an issue with this integration. I think the issue is during the configuration side.

When I use the terminal I cannot do the first step of the configuration (I have a Rasp Pi and I have installed HA directly). Here is a screenshot of what I receive:

I also have the following BLE Config:

device_tracker:
  - platform: bluetooth_le_tracker
    track_new_devices: true
  - platform: bluetooth_tracker
    track_new_devices: true

and here the sensor configuration. I took the MAC address from the Xiaomi Home APP

ble_monitor:
  rounding: true
  decimals: 1
  period: 60
  log_spikes: false
  use_median: false
  active_scan: true
  hci_interface: 0
  batt_entities: false
  discovery: false
  restore_state: false
  report_unknown: true
  devices:
    - mac: 'A4:C1:38:2A:4E:4D'
      name: 'Temperatura Abuela'
      temperature_unit: C
    - mac: 'A4:C1:38:E0:50:C6'
      name: 'Temperatura Baño'
      temperature_unit: C
    - mac: 'A4:C1:38:4B:94:73'
      name: 'Temperatura Comedor'
      temperature_unit: C
    - mac: 'A4:C1:38:AB:C1:91'
      name: 'Temperatura Trastero'
      temperature_unit: C

and this is how I see the data (Unknown).
mija2

Can anyone help me?

Thanks in advance!

The first step is not needed on full home assistant installation, only when manually installing home assistant core in a different Operating System. It is stated in the instructions.

You use three Bluetooth integrations, what might cause issues. Do you really use the other trackers? If yes, @Magalex is working on on support for device trackers in our component, so you might be able to get rid of these in the near future.

Other problem could be the requirement of an encryption key. What kind of sensors do you have?

I suggest you enable debug logging ( check the faq how to do that) and to create an issue on our github repository where we will help you find the cause of the problem and a solution. Post your logs there, normally this will tell you what the issue is.

Hi,

Thanks for the feedback! I have not thought about the encryption part. I missed that when reading the documentation and that was the main issue. I manage now to make it work, 2/3 out of 4 sensors, as depends on the moments 3 are working and 2 are working, but maybe they are defective and maybe I have to still play around to make them work, but if 2 work, it means that the problem is another. The data collection is very slow and update it’s very slow, over 10 min, so maybe I need to be more patient.

Thanks again for the support and for helping me on this! Enjoy the weekend!

Hi, repo description shows experimental support of YM-K1501.(Xiaomi Mijia Smart kettle). I am trying to setup it, but object doesn’t appear. What I’m doing wrong?

ble_monitor:
      devices:
      - mac: 'B8:7C:6F:84:xx:xx'
        name: 'Kettle'

Hello. Kettle support in public releases is very crude and doesn’t work well. Check out this github issue. Try to install the code (manually) as I wrote here.
In this github issue, we seem to have come to a good result, and full support for the kettle seem to be included in the next public release.

What’s the best way of increasing bluetooth range - can you have a network of dongles.

Hi Stepea,

I think this video will help you. It’s partially using this specific system and it has the answer on an economycal way on how to increase BT range. With my PI I’m surprised about the big range it has.

The video is interesting for your question from about min 10 : https://www.youtube.com/watch?v=K-HG7qs9hK0&t=371s

Hope it helps.

As pointed out in the video link from @juansa, ESPHome is a good option for building a large distributed system. However, many refuse this option (me, for example) because of the need to have several devices tied to power sockets.
The first thing that, in my opinion, is worth trying (if you haven’t tried it yet) is an external USB BT dongle, and preferably with a full-size antenna (like on WiFi routers and adapters). Even a small dongle usually performs better than the built-in raspberry.
Next, you should try to take this dongle away from the host (or other interfering devices) using a USB extension cable.
Since our component allows receiving data from several interfaces (hci_interface option), you can try to use several dongles, spaced apart. Our FAQ provides an example of an RJ-45 extension adapters (taken from a review by one of the users). But I myself have not tried this. The dongles carried out on two-meter usb extension cords were enough for me.

Thanks for fast reply. Well I found the problem for my kettle. It uses device ID: 1301 .
Thats original YM-K1501 MiKettle global version. Now I have two sensors (binary & temperature)

Looks like in const.py (integration 0.9.1-beta) used value for chinese version of the kettle with ID 8300

2020-12-06 20:55:16 DEBUG (Thread-3) [custom_components.ble_monitor] BLE ADV from UNKNOWN: RSSI: -73, MAC: B87C6F842B4D, ADV: 043e24020100004d2b846f7cb81802010614 1695fe 7120 1301 294d2b846f7cb8 09 0510 02 0034 b7
2020-12-06 20:55:46 DEBUG (Thread-3) [custom_components.ble_monitor] BLE ADV from UNKNOWN: RSSI: -74, MAC: B87C6F842B4D, ADV: 043e24020100004d2b846f7cb81802010614 1695fe 7120 1301 2e4d2b846f7cb8 09 0510 02 0034 b6

kettle

Hello everybody

talking about BT range, I’ve been having some weird issues with that lately. I said weird because I have the Xiaomi BT temp sensor which used to work pretty well with my BT antenna for a good while, but after few months it just decided to keep disconnecting. I tried everything I could from a “software perspective” (been thinking it was some sort of issues with the custom component or BT drivers and so on) when I realized that just by placing the sensor closer to the antenna fixed the issue. I moved it closer to the antenna for this reason, when again it started to drop the connection. And it’s always the same, if I put it closer, it reports data, as soon as I place it where it should be, it drops.

I might want to increase the BT range for this reason with a dongle or something like this, but the overall situation sounds weird to me
 Do you have a suggestion before I buy the dongle?

Yes, there was some confusion with these IDs, in the end there are now 3 of them :slight_smile: All three IDs are already included in the kettle branch and will be included in the next beta release of the component.

There is probably nothing to add to the said above.

There are too many potential causes of poor reception to explain all of them, and not to ignore any aspect of the problem. It could be a change in the workload of the 2.4GHz band, the appearance of new interfering devices, the possible dependence of the transmitter power of the device on the battery charge, degradation of some cheap elements of the device, temperature, humidity and moon phase :slight_smile: I can only say that an external dongle usually works better than a built-in adapter.

1 Like

Yeah that’s why I always prefer to have everything wired I guess :sweat_smile:

Thank you!

1 Like

thanks, i am already install kettle branch. Just one question about branch description:

The switch entity has an extra ext_state attribute. Cant find ext_state. In switch attributes I see only