MCCGQ02HL Xiaomi BT Contact Sensor

Yes, it is included in the 2023.2 release. It isn’t mentioned in the release notes, only when you click on Full changelog for Home Assistant Core 2023.2

Before 2023.2, you probably only had a battery sensor, after 2023.2, an opening sensor should be added, after the first time you open the door.

Not sure what you mean with an open/close function, but the sensor only broadcasts open/closed, so you will have a binary sensor reporting open/closed. Nothing more.

I am just getting signal strength, even after latest update 2023.2

It will (or should) most likely be added after the first time you open the door.
However, if you have e.g. the MCCGQ02HL, an encryption key will be required.
You can check if your sensor needs an encryption key in the BLE monitor documentation.

It works for me. Indeed it added new entities after I have openen/closed the door. And of course the bind key was required.

I have another observation / issue though. I still have the same door sensor available via esphome and it is constantly available there and nice continues to show all entities. At the same time, after a few minutes the one added via Xiaomi Ble integration becomes unavailable. Is that something normal? Could we have Xiaomi Ble integration behave similarly to the esphome?
Esphome:


Xiaomi Ble:

How to obtain encryption key if I have no xiaomi hub nor xiaomi cloud account, I bought sensors as stand alone, if i need hub or cloud I will toss them in garbage

1 Like

Here is the instruction:

So for door sensor you need to register on the cloud account but you do it only once and it is not needed to operate the device from HA. It is fully local integration.

edit:
I obtained keys, and I connected one sensor to HA, integration just appeared and detected sensor, but I am having trouble pairing second sensor of same kind, is there any limitation which I need to know about?
Sensor shows in my Mi Home app, and works fine, but HA does not notify me about new sensor, nor Mi BLE integration founds it, when try manually to find , it states
Xiaomi BLE
No devices found on the network

Could you please help me, which version of MiHome Mod app is able to log the encrytion key? I tried with the latest, but no pairings.txt is created when I add the sensor.

I used regular Mi home app for android, hook up the sensors to work, and then I downloaded token_extractor [Token extractor](https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor/releases/download/v1.2.0/token_extractor.exe)

fire up token extractor, enter email address of mi home and pass, selected country de, enter, and Token extractor spits all data

Thanks a lot. That worked.

1 Like

Indeed, I observed a similar behavior


In my case, it’ll become online again only every 50min (quite repeatable pattern) which makes kinda little sense for a window/door sensor especially when their jobs are watching it constantly.

I’m using ESP32 devkit board to help BT gadgets reaching HA, and I set it up with Esphome Bluetooth Proxy. Thus, I would assume that active argument shall be used (ref. here),I haven’t got time to try that out yet tho… which is already the case …I’m puzzled :disappointed_relieved:

Well, as long as you know how it behaves it might be ok. When I open the door the sensor has nicely reported the open state immediately. And closed state also right after I’ve closed it again. So it seems that the bluetooth integration is showing it offline while the sensor is sleeping - unlike when done via esphome integration it becomes unavailable only when the entire esp board is offline.

To explain what happens, some Xiaomi sensor only send data when you actually open the door or close the door, and they send a message after 1, 2, 5 10, 20 and 30 minutes (door closed). After that, it will stop broadcasting data, till you open the door again.

The Bluetooth integration (which is used by the xiaomi-ble integration) has a mechanism that tries to determine the broadcasting interval and based on that, tries to determine a time, after which the device becomes unavailable. That is exactly what happens after a while, it just hasn’t received any data for too long.

I suggest that you create an issue on github, as we need to change something for these sensors that are not broadcasting constantly. Please copy in @bdraco and me ( @Ernst79 ).

3 Likes

Hi all!
I finally managed to make it work.
Had to erase the device from the BLE.
Found out the useful command “ble_monitor.cleanup_entries” to delete the delete the sensor in BLE.
Removed the battery from the sensor and run through the setup stuff in the Xiaomi app, run the token_extractor to ge the new bindkey and entered that. Opened and closed the sensor (simulating door movement) and finaly the additional 4 entities were added. Cool.

I can confirm that it worked for me as well using amattsso’s instructions (only difference is that I could not find the clean-up service mentioned, but apparently didn’t have to). Thank you all.

I still haven’t managed to pair another MCCGQ02HL Xiaomi BT Contact Sensor, I used also Passive BLE monitor to see does BT sees sensor, and for sure it does , but Xiaomi BLE integration does not see second sensor, it just spits “no devices found on network”
2023-02-03_22-16-52

Same case with me (beside that I’m unable to pair another sensor)

Although I got it to work, I must say that it does not work well. It really can’t be used, as it is very inconsistent i noticing changes. I have had it insisting a closed door, when it was open for hours, and vice versa. I do not know whether it is a HA or Xiaomi issue, but I suspect the former.

1 Like

We are looking into it in this issue. A fix is ready (merged into development) for the motion sensor RTCGQ02LM. The door/opening sensor is next on the list to investigate.

3 Likes

PR for fixing CGH1 and MCCGQ02HL door/window sensors going unavailable is also ready, should be included in 2023.2.4. These two devices will always remain available when the PR is merged

1 Like