Passive BLE Monitor integration (Xiaomi Mijia BLE MiBeacon monitor)

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!

@baz123 I understand, but due to the lack of time, I won’t be making a fully working separate version myself. I am however thinking about moving the parsing of the ble messages (= the conversion of a large number to some useful, human readable data) to a pypi package, so it can be used in other python programs, etc. But I’m not sure when I will be able to do this.

However, regarding your issue with Bluetooth, it can be a pita when it’s not working. But I’m afraid you will get exactly the same issues when you use it stand alone, as you are right, it are base OS issues. For example, I can’t get the build in Bluetooth to work on Debian, while it is working fine on Raspberry OS and HA OS. In the end, I gave up with Debian. And this is not related to BLE Monitor, it is just the Bluetooth installation that isn’t working.

1 Like

Hi there!

Has anyone been lucky enough to get the Mi Human Body Sensor 2 activated in the TelinkMiFlasher? On my side, the device connects but disconnects after a while when activating.
It doesn’t show the Mi bind key or Mit token.

I really don’t want to buy a Xiaomi gateway.

Edit: Took a screenshot:

I’ve tried it on my MacBook, Windows 10 notebook, via a 4G hotspot but nothing seems to work… :frowning:

Just run home assistant on the other Pi. I have a handful spread around the house acting as data collectors etc. I don’t use HA OS anywhere though.

if is the RTCGQ02LM you can link it directly to mi home app without a gateway (just be sure to put the app in china mainland region), than stole the token via token_extractor.py or in any other way

unfortunately instead, seems there is no way for the water leak detector, as it is forcely asking for a gateway :frowning:

1 Like

I think it is kernel issues personally. However, if it was standalone, if you get it working you can leave the OS alone - not really an option with HA OS.

1 Like

I think it is kernel issues personally. However, if it was standalone, if you get it working you can leave the OS alone - not really an option with HA OS.

Yes, probably it is a kernel issue. But what I still don’t understand is why Bluetooth works fine on a Raspberry with HA OS for most people, while some, like you, have issues. It is the same hardware, same OS. If it wouldn’t work at all on HA OS, github would be filled with issues, but that’s not the case. On the other hand, it’s not only you, from time to time there is someone who is having these unexplainable issues. Very frustrating, I agree.

It worked! After i set the app to CN it showed up in the Bluetooth scan.
Thanks a lot!