Passive BLE Monitor integration (Xiaomi Mijia BLE MiBeacon monitor)

I am going to update on my loss of connection issues.

I have replaced the Pi4 + SSD Supervised on Raspbian with a ‘Blue’. Four days in I have not had a single disconnection and it is rock solid.

If HA is critical in running your house, I think the only way forward is to get a Blue.

YMMV.

1 Like

I’m running on Supervised, i’ve tried everything you said BUT…i found my solution…
I’ve said that i had installed Room Assistant in my HA before, so, even if it was uninstalled i found a folder called room-assistant in my configuration files. I decided to delete it. My problem solved. I don’t know how. No freezes.

1 Like

First, I want to say thank you to both @Magalex and @Ernst for this fabulous integration.

Second, just wanted to let you know my setup

  1. Retired HP Laptop (i5) running Proxmox
  2. HassOS in a VM
  3. Using built in bluetooth
  4. Using stock firmware on three LYWSD03MMC. I am ok with getting temperature/humidity every 10 minutes so I saw no need to change firmware.

Instructions were terrific. Used Xiaomi Cloud Token Extractor to get encryption keys. Used the GUI method in Integrations. Only one caveat I would say is to add to the instructions about if you use Fahrenheit. One of the first things I did was to change the display to be in Fahrenheit via the Mi Home app. Once I used your excellent integration, I selected Fahrenheit in the options. My temp was giving me the degrees in Celsius, but using the F suffix. I figured since it was converting back to Celsius, if I chose Celsius in the integration, it might go back to Fahrenheit, and I would just change the suffix to specifically be F. But as soon as I put it to Celsius, it displayed as the correct temperature in Fahrenheit in love lace. But that was only a 3 minute “what is going on” issue! But it might help others if you put this in your instructions.

But I really just wanted to say thank you. I purchased three of these units to see how well they worked and the range I would get. I haven’t yet tested every room in my house, but I think it should work, and if it doesn’t you listed great options.

Again, thank you.

Thanks, I’ve updated the instructions. Keep in mind that.

  • HA is always converting F or °C to your Unit System as set in Configuration - General

image

  • Changing the setting in BLE Monitor to F is only needed for custom ATC firmware, if you set the display to F. The reason is that the sensor starts to send BLE data in F as well.
  • Changing the setting to F in MiHome does not affect the way the sensor sends data, so the conversion is done in the app, the sensor still sends data in °C
1 Like

Got it. Makes sense now!

I use 1.3.1 and Hass OS 2021.3.4 but can’t submit the options in the integrations UI. Just getting thrown back to the first popup when submitting the “configuring device”. Any advice?

Do you mean that when you change the “device” options, you go back in the “integration” options menu after clicking submit. That’s OK, just click submit again in the “integration” options menu, and things should be changed.

Thanks for your super fast response! I get it, I can find my device in the settings before submitting so it should be fine. But then? I can´t find my device in the UI, where are the settings stored (like the mac and encryption key)? Sorry for the newbie questions but I´m kind of lost.

You normally have to do the following.

  • Open the options menu of Passive BLE monitor.
  • Click on devices and in the drop down menu,
  • Click on a MAC address of the sensor you wants. This list is automatically filled with MAC addresses of sensors nearby, as long as you have set the option “discovery” to enabled. Note that discovery can take a few minutes, depending on the sensor you have (some are fast, some can take up to 10 minutes).

  • After selecting your mac, click on image and a new window should open. Here you can change your device settings.

  • click on submit and you will return in the previous menu.
  • Click on submit again and the integration will reload. Wait a few minutes and sensors should work.

Thanks,
Thats what I did:


image

I´ve reloaded the integration, restarted the OS. No devices to be found, nothing in the logs and the config is validated.
That´s why I asked where the values in from the options menu are stored. Can´t find them here /config/custom_components/ble_monitor/ but maybe I haven´t looked deep enough?

ah, your settings look fine.

To get more insight what is wrong, you should enable debug logging. Add this to configuration.yaml and the log of HA should show a lot of messages in the log (after a restart), which could help you find the issue.

logger:
  default: warn
  logs:
    custom_components.ble_monitor: debug

I propose you create an issue on github and we look into this further. Issues can be reception issues, wrong hci port, wrong encryption key, etc. Just post you log in the issue and we will help you out.

Is there a way to specify the number of decimals per sensor type? For example I only want 0 decimals for illumination / lux sensors, but 2 for the rest.

No, currently not. You can only define the number of decimals per device.

As a workaround, you can set the decimals to the highest number of decimals and use template sensors for the sensors which you want to decrease the number of decimals.

A request to take care of this is in general, in lovelace is here, Formatting numbers in Lovelace I think a solution like this in the UI would be better as a general solution.

1 Like

I have been using this integration for a while now and it has been working great. I have 7 LYWSD03MMC devices configured. This morning I rebooted my HA server for some unrelated code changes and lost all of these devices. I have rebooted before several times without issue. Is there a way to get them back or do I need to remove them all and start over?
Thanks

What do you exactly mean by “lost”? Are they just unavailable or are they totally gone, no trace left?

Either way, with BT devices it can take a while until they are back. If you don’t depend right now on these sensors, wait a bit, and restart your server (not only HA).

If this doesn’t help, you need to give more information about your specs. Also check the BT on OS level, maybe there is something not running (bluetooth.service, hci0, hci1…).

Ok, Thanks for the reply.
They all show as unknown in Developer Tools.
I can run TelinkMIFlasher and see all 7 devices and can pull readings and set things like time etc.
I can do this from a separate Windows10 laptop and from the dedicated I7 computer that is running latest release of HA (2021.3). I can see the i7 HA computer’s bluetooth on the laptop when scanning for BT devices. So BT is on and running.
All Devices have LYWSD03MMC, Software Version: 2.9 firmware installed.
All of these Mi devices have been working flawlessly. until this reboot. I ran it for 30 hrs and these 7 devices x 4 readings each are still unknown. I rebooted again just in case but no help. That was 3 hours ago. All other devices, sensors etc. used in Home Assistant (about 75) are working without issue. This integration is the only issue.
I am using Passive BLE monitor, Bluetooth Low Energy Monitor through configuration / integrations and it shows [7 devices]{28 entities].
History: When first installing these I started with 4 devices. Later added 3 more. During that time I lost some of the first 4 just like this. The only way I was able to get them up and running again was to delete them through Passive BLE Monitor and bring them back. After doing this all 7 have been solid and backup through several reboots over a few weeks.
Just was hoping there is another way or that I am doing something that causes this. It seems that it will happen again.

I see you use ATC firmware, pvvx version, is that correct? There has been a change in this firmware version 2.9 in the advertisement format. I fixed that in BLE monitor in the latest version, but I might have missed something. I assume you have updated BLE monitor to the latest version, otherwise try that first.

If that doesn’t work, Please open an issue on GitHub and post a hcidump, if possible, instructions on how to create a hcidump are in the faq.

Another thing to try is to enable debug logging and check if you see something strange (or post it on github, I will check it for you).

OK thanks, will do.
Update: Update did it!
I went and checked HACS and sure enough there was an update available. I don’t go to HACS often unless I want to install something. So missed this. I have HACS set to show on the left menu but wish there was a red dot that showed up when updates were available. Anyway, my fault. All looks good. Thanks so much for your help…

Today, version 1.5.2 is released. Please note that there is a very limited breaking change although most people won’t notice a difference

Changes

We added a new configuration option bt_interface to specify the MAC address of your Bluetooth interface (e.g. Bluetooth dongle or build-in Bluetooth).

bt_interface is an alternative for the current hci_interface option. With bt_interface you specify the MAC address of your Bluetooth interface, in stead of the HCI number. The reason for adding this option is that the HCI interface number can change, e.g. when restarting Home Assistant, while the MAC address won’t change. It is therefore advised to use bt_interface. For backwards compatibility the hci_interface option is still available.

When using YAML to configure BLE monitor, Home Assistant will show the available MAC addresses in the Home Assistant logs when starting up (check the log). When using the User Interface to configure BLE monitor, your old hci config will be converted to the corresponding MAC address(es) automatically. In the UI, you can only select MAC addresses (a selection list of available MAC addresses will be automatically generated and presented as a selection list).

The breaking change is that, when not specifying a MAC address or HCI number, by default the first MAC address will be used in stead of hci0.

Note that hci_interface will overrule bt_interface when using both options at the same time.

2 Likes

@Ernst I know it has been said before, but I really wish there was a version of this that could be run on a Pi completely separate from HomeAssistant.

The interaction between Bluetooth, linux (esp kernel) and HA OS is so tetchy - just upgraded to HA OS 5.13 and all sorts of issues that I am sure are base OS issues.

When it works it is fantastic!