Passive BLE Monitor integration (Xiaomi Mijia BLE MiBeacon monitor)

Hello, @drjam7
You are not the first to have this error. I dig. No good news yet.
Here you can follow the progress.

1 Like

Hi, @Kabala
There are different reviews about working on the built-in bluetooth. Try it.
Except ble_monitor: you donā€™t need to enable anything. All configuration options are described in our documentation.

Hi all and especially @Magalex

First of all thanks for your effort in creating this and also responding to so many queries from your users. Your dedication is admirable.

I hope you can help with getting me started with your addon.

Iā€™m trying to get readings from my LYWSD03MMC with custom ATC firmware and some Vegtrug plant sensors. Iā€™m using HA on a NUC virtualized on ProxMox, and have passed though the BT hardware to the HA vm. On the VM Iā€™m able to scan for BLE and I see the devices.


>> hcitool -i hci0 lescan
....
A4:C1:38:78:81:53 ATC_788153 << LYWSD03MMC 
C4:7C:8D:6B:9D:E9 Flower care  << vegtrug

I installed your custom component with HACS, version 0.8.3 an created some config in configuration.yaml to start with:

ble_monitor:
  rounding: True
  decimals: 1
  period: 60
  log_spikes: False
  use_median: False
  active_scan: False
  hci_interface: 0
  batt_entities: False
  discovery: True
  restore_state: False 
  report_unknown: True
  devices:
    - mac: 'A4:C1:38:78:81:53'
      name: 'Room1'
      temperature_unit: C
    - mac: 'C4:7C:8D:6B:9D:E9'
      name: 'Flower Care1'

Logs show:

2020-11-24 20:16:51 DEBUG (Thread-6) [custom_components.ble_monitor.sensor] HCIdump thread: joining
2020-11-24 20:16:51 DEBUG (Thread-102) [custom_components.ble_monitor.sensor] HCIdump thread: main event_loop stopped, finishing
2020-11-24 20:16:51 DEBUG (Thread-102) [custom_components.ble_monitor.sensor] HCIdump thread: Run finished
2020-11-24 20:16:51 DEBUG (Thread-6) [custom_components.ble_monitor.sensor] HCIdump thread: joined
2020-11-24 20:16:51 DEBUG (Thread-6) [custom_components.ble_monitor.sensor] Spawning HCIdump thread
2020-11-24 20:16:51 DEBUG (Thread-6) [custom_components.ble_monitor.sensor] HCIdump thread: Init
2020-11-24 20:16:51 DEBUG (Thread-103) [custom_components.ble_monitor.sensor] HCIdump thread: Run
2020-11-24 20:16:51 DEBUG (Thread-6) [custom_components.ble_monitor.sensor] 0 HCI Events parsed, 0 valuable MiBeacon BLE ADV messages. Found 1 known device(s) total. Priority queue = 0
2020-11-24 20:16:51 DEBUG (Thread-103) [custom_components.ble_monitor.sensor] HCIdump thread: connected to hci0
2020-11-24 20:16:51 DEBUG (Thread-103) [custom_components.ble_monitor.sensor] HCIdump thread: start main event_loop

After about an hour one of my Vegtrugā€™s is found, but Iā€™m not getting any data from it (entities show no data)

LYWSD03MMC is not found at all. Iā€™ve flashed the custom ATC firmware on this unit. Is this supported, or can I only use the original firmware on the LYWSD03MMC for it to be discovered by your addon?

Could there be an issue with my BLE reception?

Thanks,
Hap

Hello, @hapklaar ! Thanks for the kind words.

Based on the fact that an entity was created for your sensor, we can conclude that the component is working, however, the text ā€œ0 HCI Events parsedā€ in your log is still alarming. Yes, it could be a reception problem. But first, you should pay attention to the following nuances:

Many sensors start sending valuable messages only after adding and ā€œpairingā€ them in the official app (MiHome, Flower Care, etc). In addition, there is some confusion with VegTrug sensors (if I understand correctly) - some of them (with a mac address starting with C4) seem to be FlowerCare sensors and only work with the Flower Care app (not VegTrug). It is also worth checking for firmware updates in the application - for many, the problem was solved exactly at this step. Look at this github issue.

As for LYWSD03MMC - yes, custom firmware is supported. The only condition is that the MiLike option must be activated when reflashing the sensor. Make sure this has been done.

The very first thing to try in case of reception problems is to place the sensors as close to the host as possible. We can think further depending on the result.

Hey @Magalex,

I think reception issues with the internal BT chipset in my NUC were the cause of my problems. Iā€™m now testing with a TP-Link external BT USB adapter and immediately get much better results:

DEBUG (Thread-6) [custom_components.ble_monitor.sensor] 1460 HCI Events parsed, 15 valuable MiBeacon BLE ADV messages. Found 3 known device(s) total.

Iā€™m going to play with it this weekend and see if I can get all my devices recognized :slight_smile:

Yes, external BT USB adapter usually works better than built-in one. I myself want to search and buy one with full-sized external antenna.

1 Like

I have no idea what Iā€™ve done but I rolled back, then updated to 0.118 again and used the ble_monitor integration and everything now works!

Thanks for all your work on this integration @Magalex!

Hello! How to make the Home Assistant window / door sensor show open / closed instead of on / off. Thanks!

Thanks for the kind words. Just in case, I want to note that I am not working alone, without @Ernst, I think, everything would have died long ago ) And maybe it wouldnā€™t have started at allā€¦

@mio This is what we are currently working on. You need to either be patient a little, or before the release of the new version use template binary sensor.

1 Like

@Magalex Thanks for your component! This is exactly what I was looking for.
I looked at the templates of binary sensors but did not understand where to replace on with open.

Try to replace your sensor py file with the sensor.py from the repo. THen you can add device_class opening in config.
https://raw.githubusercontent.com/custom-components/ble_monitor/05a80e4d50181e15369839852760ac7686e3338a/custom_components/ble_monitor/sensor.py

Classes have long been registered in the component (easily checked in the entity attributes). The fact is that an entity is created using the add_entities method obtained in the sensor platform. This method is obtained during the platform initialization stage. The component now creates all entities in the sensor domain. Binary_sensor classes donā€™t work here.
Soon, the component platform will be split into two, sensor and binary_sensor, after which the switching sensor entities will be created in the binary_sensor domain, and the classes will start working.

OK! Iā€™m looking forward to the next release.Tthanks!

  • [BREAKING CHANGE] now the component spawns binary_sensor entities, that is, the binary sensor classes now work. After the update, new entities in the binary_sensor domain will be created for all your binary sensors.
  • experimental support for YM-K1501 (Xiaomi Mijia Smart Kettle)
  • minor fixes and improvements

Donā€™t forget to delete old binary sensor entities in the sensor domain.

1 Like

@Magalex, thanks !!! This is the data added to Home Assistant using the latest version of your component:

1 Like

currently home assistant is installed on an old PC I had, no bluetooth - i was thinking of using a pi zero as the bluetooth receiver and then sending this to the HA PC through mqtt. Is there a way of doing this ?

Hello. I donā€™t know a way to solve this issue in the case of our component and MQTT.
I suggest looking at the custom component Remote Home-Assistant.

so the best way in my case is to have a bluetooth dongle connected to the HA PC.

@stepea You can connect Bluetooth USB dongle to your computer

Yes, thatā€™s a good option. Especially if you take the receiver away from the computer on an extension cord.

Alternatively, it is worth mentioning ESPHome on the ESP32 board. I myself, however, have not used this solution for a long time, so I cannot reliably talk about the advantages / disadvantages of this method now. I can only say that with the appearance of our component, they seriously expanded the list of supported sensors :slight_smile: