MCCGQ02HL Xiaomi BT Contact Sensor

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”

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.


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

@Ernst, what is the door left open sensor?
Is it time-based? If so, is the duration configurable?
I didn’t find any HA doc anywhere that explains this sensor. Is there anywhere?
Thanks a lot!

It is broadcasted by the sensor, this is from the official MiBeacon specs (use translation for that page to get it in English)


If it sends 2, you have left the door open too long. Don’t know what “too long” is. It’s not configurable, its just as the sensor sends it. If you want to have your own door left open sensor, just make your own template sensor in HA, that is triggers x minutes after a state change from closed to open.

1 Like

Thank you @Ernst for clarifying.
Note below that on the Xiaomi Home app UI (when used in English), the timeout category is called “Timeout, not closed”.

For reference, here is the list of possible MCCGQ02HL events as shown on the Xiaomi Home app:

@Ernst, one more question. The MCCGQ02HL also has a light sensor.
When using the MCCGQ02HL with the Xiaomi Home app, the app reports that the device is either in “Bright ambient light”, or in “Dim ambient light”.

Can the light sensor also be added to Home Assistant?

Isn’t there a light binary sensor already? It should be.

1 Like

@Ernst, I see no binary sensor for light.
All I see on the device page is this:

Can you enable debug logging for the Bluetooth integration and the xiaomi-ble integration and sends me the logs. I also need the MAC address and the encryption key, you can send me the info in a private message. (You can change the encryption key afterwards by resetting the sensor and re-adding it to MiHome, if you want).

1 Like

After about a day, the Light sensor started showing up in Home Assistant. This long delay was due to a Bluetooth issue on my HA that is probably unrelated to xiaomi-ble or MCCGQ02HL.

For those that are interested, here are more details:

But first, I want to thank @Ernst for his help in debugging this issue.
He identified that I have the following recurring message in my logs about every 2 minutes:

INFO (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (XX:XX:XX:XX:XX:XX): Bluetooth scanner has gone quiet for 90s, restarting

The repeating BT adapter restarts take a while, and messages are not received during the adapter restart. To fix it I deleted the “Bluetooth” integration (using the HA UI), rebooted by Raspberry PI, and then add the Bluetooth integration back.

1 Like

Hi all!
I’ve been playing some more with this sensor and think it has potential.
Anyway I havn’t yet figured out what integration to use.
I’m using booth the BLE Monitor side-by-side with the Xiaomi BLE.
Don’t know if this is the way - probable not. The Xiamomi should be the one to use I suppose as it is custom made but I find some oddities. I can’t find all sensors on the BLE but the Xiamoi on the other hand often shows them as “Unavailable”.
The normal BLE integration is much faster and accurate.The Xiaomi sometimes doesn’t record the changes which is the prio 1 entity given the type of sensor.
Have a look at the sceenshots. They were done the same time.


Anyone else that has made the same findings and perhaps found a solution?

EDIT: Found out that one of my ESP32 with BLE Proxy was down. When this one was up again I got instant reply

Strange that the sensor could communicate with my “normal” Bluetooth adapter using BLE but that the Xiaomi couldn’t. I wonder - Is there some way to see who communicates which way?

I am having problems with those sensors since I bought them, one is working quite ok (for now), other I never managed to pair, it is impossible to pair it, even if MI app shows that sensor work properly.

Using BLE monitor and HA Bluetooth integrations can cause this behavior, especially when one is using active scanning, while the other is using passive scanning. Both integrations want to use the same Bluetooth adapter in a different scanning mode, which is generally won by BLE monitor. This will make the core HA Bluetooth integration miss messages. Try to use only one type of scanning for both. Both the Bluetooth integration as well as BLE monitor have a setting for this.

Hi Ernst. I really appreciate all the work you are putting into this. The 2023.2.4 improved the responsiveness, but at least my MCCGQ02HL is not at all consistent in reporting open/close. It is a total hit and miss most of the time. I can leave it open for hours, and it insists it it closed, and vice versa. Is it just mine/my installation or is this a know bug?


Ernst, this is exactly what I’m seeing.
Everything works for a time while using both BLE Monitoring and HA Bluetooth.
Then suddenly I start getting no answers from one source.
After resetting the Bluetooth integration (Reload) everything is back working again.
I very much like the idea of using passive BLE monitoring (due to battery savings) but it seems like I have to have active running in order for some of my senors. Will this ever work?

If you need active scanning for one of your sensors, you should use active scanning. It is either passive or active for all sensors, there is no way to set this per sensor. This is due to the fact that this is a setting for the Bluetooth adapter, not a sensor setting.