Passive BLE Monitor integration (Xiaomi Mijia BLE MiBeacon monitor)

Hi @Magalex,
thanks for having a look into my current problem.
The output uname -a is

 Linux pop-os 5.4.0-7642-generic #46~1598628707~20.04~040157c-Ubuntu SMP Fri Aug 28 18:02:16 UTC  x86_64 x86_64 x86_64 GNU/Linux

and the bluetooth wifi bt chip is 1286:204b Marvell Semiconductor, Inc. Bluetooth and Wireless LAN Composite Device
The Logs of Docker and syslog are both showing errors related to python.

Any suggestion or should i just buy a external bluetooth adapter?

@MrLemur, thanks for sharing this!
We have a request for a standalone parser that could be used outside of HA. I think that sooner or later we will come to this :slight_smile: Now there are many other tasksā€¦

1 Like

You didnā€™t say which version of the Hassio image you are using. Version 4.14 has a serious bug with bluetooth - you need to use 4.15.

If possible, you should try an external dongle, yes. I have no other thoughts yet. I will try to google your wifi / bt adapter.

The only thing that comes to mind when I think about combined adapters is a problem similar to yours, but the opposite, when serious wifi-traffic disables the bt-communications.

Hi to all!

A major component update is coming. Serious not by the number of changes, but in their essence.
We collected all the planned breaking changes, and decided to make them together to hurt our users only once :slight_smile:

First, we changed the name of the component to ble_monitor (the repository name and the folder name with our component will change accordingly). This had to be done since the old name no longer reflects the essence of the component, and the new name gives us the freedom to implement support for other protocols (in addition to Xiaomi Mijia BLE MiBeacon) and expand the functionality of the component beyond receiving readings from sensors.

The prefix of the sensor entity names will be changed accordingly: from mi to ble.

The configuration of the component has been moved from the sensor platform level to the integration level - this also gives us more freedom in the further development of the componentā€™s functionality.

The structure of the configuration itself has also changed - the settings are grouped into the ā€œper deviceā€ order.

The process of applying changes started today by renaming the repository and publishing version 0.8.1-beta. Letā€™s test its several days, and we will make a full release.

@Ernst prepared a great guide for configuration updating. Please read it carefully before updating!
We strongly recommend that you register custom names for each of your sensors before updating (with the name option) - it will be much easier to find new entities of your sensors after updating. Do not forget to also delete old entities after updating.

We hope this transition goes smoothly for you, and we will be happy to answer any questions you may haveā€¦

1 Like

migration completed, no issues so far
guide is very well documented, easy to follow and clearly explained

1 Like

Iā€™d have suggested creating a new component and eventually depreciating the old one.

Does this mean that on the next HA update, it will fail to find the old component?

We have chosen to not create a new component, as this would mean that we loose all issues in our repository. It would also result in people not knowing that the old mitemp_bt component is not being updated anymore.

You can still use the old mitemp_bt configuration if you donā€™t want to change (now), it is as simple as not updating the custom component to 0.8.x in HACS. Just stay on 0.7.x and you can still use the old mitemp_bt configuration. You can even go back in HACS, if you accidently have updated.

Nothing will happen on the next HA update, it will keep on working, both the old 0.7.x mitemp_bt version, or the 0.8.x ble_monitor version, whichever you choose.

1 Like

Thanks - ainā€™t broke, donā€™t fix, BTW, how do you select a specific version of a component in HACS? Iā€™m actually still on 0.6.13 :laughing:

Thatā€™s easy. Click on the three dots on the card in HACS and select reinstall. You can choose whichever version you want (last 5 versions + master).

If you want older versions, you have to go to the repository, lookup the version you want in Releases and overwrite the files in the custom_components folder manually.

1 Like

Thanks for the heads up. I have only used auto discovery, so I have no per device config today.

If I read your message correctly, this means that all I have to do is add

ble_monitor:

to configuration.yaml

And after restart of HA and upgrade of ble_monitor, it will work as before, BUT, all the sensors will now be renamed from e.g. sensor.mi_c_80eaca88dcd1 to sensor.ble_c_80eaca88dcd1 etc. so I need to update my automations and frontend (and plants) with the new sensor names?

Unfortunately, yes, you will have to update all the locations where the sensors are used.

That is fine. (One of the good things with yaml-config is easy search and replace).
I just wanted to be sure that I do not have to add all the sensors mac-addresses to the config.

Edit:

All sensors were added. The names changed from

sensor.mi_c_80eaca88dcd1

to

sensor.ble_conductivity_80eaca88dcd1

That is fine. A quick search and replace fixed that.

I wonder what version of Home Assistant do you have?

You can also go into Configuration > Entities and change the entity IDs and names. I did that originally when it was at the platform level and, after updating, I just deleted the old entities and renamed the new ones with the same IDs. Easier than changing every script and automation.

1 Like

0.117.5 running on Raspbian Buster witha Supervised install.

Easy but not obvious! Many thanks.

As I said, I tried to reflash and change the mi like, it did nothing :wink:

Hello people,
canā€™t get this integration to work running HassOS on proxmox with bluetooth working, 3x LYWSD03MMC with custom firmware and beta integration :thinking:

Line 5652: 2020-11-14 18:30:50 DEBUG (SyncWorker_42) [custom_components.ble_monitor.sensor] Starting
Line 5782: 2020-11-14 18:30:50 DEBUG (SyncWorker_42) [custom_components.ble_monitor.sensor] Spawning HCIdump thread(s).
Line 5783: 2020-11-14 18:30:50 DEBUG (SyncWorker_42) [custom_components.ble_monitor.sensor] HCIdump thread: Init
Line 5784: 2020-11-14 18:30:50 DEBUG (SyncWorker_42) [custom_components.ble_monitor.sensor] HCIdump thread: Init finished
Line 5785: 2020-11-14 18:30:50 DEBUG (SyncWorker_42) [custom_components.ble_monitor.sensor] Starting HCIdump thread for hci0
Line 5786: 2020-11-14 18:30:50 DEBUG (Thread-7) [custom_components.ble_monitor.sensor] HCIdump thread: Run
Line 5787: 2020-11-14 18:30:50 DEBUG (SyncWorker_42) [custom_components.ble_monitor.sensor] HCIdump threads count = 1
Line 5788: 2020-11-14 18:30:50 DEBUG (SyncWorker_42) [custom_components.ble_monitor.sensor] 0 encryptors mac:key pairs loaded.
Line 5789: 2020-11-14 18:30:50 DEBUG (SyncWorker_42) [custom_components.ble_monitor.sensor] whitelist: [A4:C1:38:5D:26:A1, A4:C1:38:C6:92:F1, A4:C1:38:10:84:5D]
Line 5790: 2020-11-14 18:30:50 DEBUG (SyncWorker_42) [custom_components.ble_monitor.sensor] 3 whitelist item(s) loaded.
Line 5792: 2020-11-14 18:30:50 DEBUG (Thread-7) [custom_components.ble_monitor.sensor] HCIdump thread: Connection
Line 5793: 2020-11-14 18:30:50 DEBUG (Thread-7) [custom_components.ble_monitor.sensor] HCIdump thread: Connected
Line 5794: 2020-11-14 18:30:50 DEBUG (Thread-7) [custom_components.ble_monitor.sensor] HCIdump thread: start main event_loop
Line 5868: 2020-11-14 18:30:51 DEBUG (SyncWorker_42) [custom_components.ble_monitor.sensor] update_ble called
Line 5869: 2020-11-14 18:30:51 DEBUG (SyncWorker_42) [custom_components.ble_monitor.sensor] First run, skip parsing.
Line 22261: 2020-11-14 18:31:51 DEBUG (SyncWorker_32) [custom_components.ble_monitor.sensor] update_ble called
Line 22262: 2020-11-14 18:31:51 DEBUG (SyncWorker_32) [custom_components.ble_monitor.sensor] Discovering Bluetooth LE devices
Line 22263: 2020-11-14 18:31:51 DEBUG (SyncWorker_32) [custom_components.ble_monitor.sensor] Time to analyzeā€¦
Line 22264: 2020-11-14 18:31:51 DEBUG (SyncWorker_32) [custom_components.ble_monitor.sensor] Getting data from HCIdump thread
Line 22265: 2020-11-14 18:31:51 DEBUG (SyncWorker_32) [custom_components.ble_monitor.sensor] HCIdump thread: joining
Line 22266: 2020-11-14 18:31:51 DEBUG (Thread-7) [custom_components.ble_monitor.sensor] HCIdump thread: main event_loop stopped, finishing
Line 22267: 2020-11-14 18:31:51 DEBUG (Thread-7) [custom_components.ble_monitor.sensor] HCIdump thread: Run finished
Line 22268: 2020-11-14 18:31:51 DEBUG (SyncWorker_32) [custom_components.ble_monitor.sensor] HCIdump thread: joined
Line 22269: 2020-11-14 18:31:51 DEBUG (SyncWorker_32) [custom_components.ble_monitor.sensor] Spawning HCIdump thread(s).
Line 22270: 2020-11-14 18:31:51 DEBUG (SyncWorker_32) [custom_components.ble_monitor.sensor] HCIdump thread: Init
Line 22271: 2020-11-14 18:31:51 DEBUG (SyncWorker_32) [custom_components.ble_monitor.sensor] HCIdump thread: Init finished
Line 22272: 2020-11-14 18:31:51 DEBUG (SyncWorker_32) [custom_components.ble_monitor.sensor] Starting HCIdump thread for hci0
Line 22273: 2020-11-14 18:31:51 DEBUG (Thread-17) [custom_components.ble_monitor.sensor] HCIdump thread: Run
Line 22274: 2020-11-14 18:31:51 DEBUG (SyncWorker_32) [custom_components.ble_monitor.sensor] HCIdump threads count = 1
Line 22276: 2020-11-14 18:31:51 DEBUG (Thread-17) [custom_components.ble_monitor.sensor] HCIdump thread: Connection
Line 22277: 2020-11-14 18:31:51 DEBUG (SyncWorker_32) [custom_components.ble_monitor.sensor] Finished. Parsed: 3 hci events, 0 xiaomi devices.

using this config:

 ble_monitor:
   discovery: False
   devices:
     - mac: 'A4:C1:38:5D:26:A1'
     - mac: 'A4:C1:38:C6:92:F1'
     - mac: 'A4:C1:38:10:84:5D'

Am I missing something?

Thanks in advance

Configuration looks ok, assuming that you use 0.8.1 beta. Component is working as it should be, it is just not recognizing the sensors as Xiaomi sensors.

Did you flash the custom firmware with advertising type set to ā€œmi likeā€? See this topic.

Thatā€™s what I missed :sweat_smile: Iā€™m trying and will report, thanks :ok_hand: