MCCGQ02HL Xiaomi BT Contact Sensor

@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)

image

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.
BLE


Xiaomi

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?

/Erik

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.

I’ve bought quite a bunch of MCCGQ02HL door sensors and unfortunately I cannot make them work in HA. They are detected but only with the signal strength and no matter what I do the binding key process doesn’t pop up.
I have some Temperature/Humidity sensors (lywsd03mmc) and they work fine with binding key and all.
My HA version is 2023.3.1… what should I do different? I followed all the steps described in this thread…

I have added it and just waited. They don’t report data too often. You can try to open/close it or expose to light/cover it so that it starts sending some data. After that HA should just ask for the binding key. Make sure you don’t add it to the app after you retrieve the binding key as pairing with the mobile app is changing the key.

they are added since 3 days now and did all the open close from time to time but still nothing…

Do you see them in Xiaomi BLE integration? I think that’s the only integration that is able to recognize all sensors.
image

Yes, they are visible

So I managed to add a sensor with the open/close status. I’ve added it once in the xiaomi home app and after that the binding key flow poped up in ha also