Some Xiaomi sensors need to be added in MiHome first, before they start broadcasting data. This is to create/set/exchange the bind key. After that, they should work in HA.
Not all sensors do need this, but some do. The MCCGQ02HL seems one of them.
Some Xiaomi sensors need to be added in MiHome first, before they start broadcasting data. This is to create/set/exchange the bind key. After that, they should work in HA.
Not all sensors do need this, but some do. The MCCGQ02HL seems one of them.
Hi Ernst,
I have tried deleting, re-adding it to MiHome, and readded it to Home assistant with the new bindkey. It works, but very poorly, as it reports only a fraction of the open/close events, and is stuck in one or the other. Is that just the lay of the land right now, or does anyone have any success with this device?
It works pretty ok for me. The only downside is that it shows unavailable most of the time but updates status ok when opened/closed. Iâm using it in the post box outside and the nearest esp32 bluetooth hub is ~3 meters away. Post box is full metal and the sensor is inside.
There can be many reasons for this behavior, but is is often bad reception. Try to use an extension cable with external dongle, if you use a dongle, Also avoid WiFi devices close to your Bluetooth radio. WiFi can totally block Bluetooth signals. You could also try to use a new battery in the sensor.
Are you using the latest HA version? I have added this device as sleepy device, which should not go to unavailable (only after a restart, which still has to be fixed).
Yes, always the latest available. Here is how it looks:
Iâve tried the device right next to the Raspberry Pi running HA, so reception shouldnât be a problem, but of course the Raspberry has both wifi and bluetooth, so there could be interference, but in that case I will never get a working solution. Tried changing battery - still same experience. I think I have to give up on this device and move to the Aqara zigbee based devices - they are much more stable.
Hi Digidolphin,
I have the same problem and also use RPi4 with built-in BT adapter. It is interesting that, if look at the logs, all messages reach the RPi4, but in most cases the state does not change. Do you run Raspberry Pi OS? Which version of BlueZ do you use?
Hi Ernst,
I have the same behavior, the integration reports only a fraction of the open/close events. Interesting that all the events are processed at some level, if I close/open the door, I see new entries in the logs. But the sensor state is not updated. At the same time Passive BLE Monitor works fine, so probably there is a problem in the native BLE integration.
Hmmm, that is strange. When the state stays the same in a new BLE message, HA wonât update the state.but I guess in your situation, you have the problem that it doesnât even update a changed state of the door. Can you post one of the logs of a message that doesnât change the state?
Hi Ernst, sure. I did a simple experiment: I opened and closed the door every 30 seconds for six minutes. Each time I received an event in the logs, but the state of the sensor in the HA changed only 3 times out of 12. Here is a log message that doesnât change the state:
2023-03-26 12:23:08.910 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (XX:XX:XX:XX:XX:XX) [connectable]: E4:AA:EC:6F:A0:A6 AdvertisementData(local_name='standard demo', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b'0X\x8b\t\xd0\xa6\xa0o\xec\xaa\xe4\x08'}, rssi=-49) match: set()
2023-03-26 12:23:08.910 DEBUG (MainThread) [xiaomi_ble.parser] Parsing Xiaomi BLE advertisement data: <home_assistant_bluetooth.models.BluetoothServiceInfoBleak object at 0x7f7c7ecfc0>
2023-03-26 12:23:08.911 DEBUG (MainThread) [xiaomi_ble.parser] Advertisement doesn't contain payload, adv: 30588b09d0a6a06fecaae408
And here is a log message that change the state:
2023-03-26 12:26:30.789 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (XX:XX:XX:XX:XX:XX) [connectable]: E4:AA:EC:6F:A0:A6 AdvertisementData(local_name='standard demo', service_data={'0000fe95-0000-1000-8000-00805f9b34fb': b'XX\x8b\t\xe3\xa6\xa0o\xec\xaa\xe4Vj\xc9K\n\x00\x007)\xa7\xa7'}, rssi=-34) match: set()
2023-03-26 12:26:30.790 DEBUG (MainThread) [xiaomi_ble.parser] Parsing Xiaomi BLE advertisement data: <home_assistant_bluetooth.models.BluetoothServiceInfoBleak object at 0x7f7c7ee3c0>
So itâs very strange because some messages do not contain a payload. I am trying to debug, but no progress so far.
Settings: HA 2023.03.6, RPi4, Passive BLE Monitor was removed. I have some other Xiaomi BLE devices (Kettle, temp sensors) and it works great.
I compared how Passive BLE Monitor and Xiaomi BLE process messages from âMCCGQ02HLâ. For each action (closing/opening door), the sensor sends two or three messages, one of which has a payload.
_parse_xiaomi()
called one time in Xiaomi BLE. Probably there are missing packages because each time packet_id
is incremented by 3 or 2. In the most cases, packets do not contain a payload.
parse_xiaomi()
called 2-3 times in BLE monitor. Exactly one message has payload and the state changes.
Maybe someone has an idea how to localize the problem with Xiaomi BLE?
Hi Ernst,
Thank you for developing an amazing integration for BLE devices. This is the fastest and most accurate BLE tracker I can find. However for an unknown reason, somehow the integration stopped working.
It worked well and then all my door sensors are unavailable (temperature/humidity & smoke sensors are still working fine). It only shows battery & rssi - all unavailable.
I have Xiaomi BLE, Xiaomi Miot and Passive BLE installed at the same time. Was it the reason?
Should I delete them all and try to install Passive BLE from the start?
I had the same issue and I had to reinstall all devices again.
Now, all is fine.
Sorry for the late reply. Running the Bluetooth integration and BLE monitor at the same time can cause issues, when they both want to use the same Bluetooth dongle. Make sure they are running both integrations same scanning mode (passive or active, as long as it is the same for both). If that doesnt work, try to use a second Bluetooth dongle, one for each integration.
Update: the problem is somehow related to the Bluetooth stack on the RPi (the latest Raspberry Pi OS) + implementation details of official BLE component, which miss a significant share of advertisements
(custom-components/ble_monitor didnât miss ,so itâs not a signal strength problem). ESPHome + Bluetooth proxy solved the issue.
Iâm trying to get my head around this as I like to get some MCCGQ02HL for my home. I like the size (theyâre a replacement for the Wyze contact sensors that are no longer available).
Am I right to say there are two ways to integrate these sensors:
Iâd like to use the second method as the HA server is too far away for some of the planned locations of the MCCGQ02HL.
Lastly I understand the MCCGQ02HL has encryption keys which would have to be retrieved. Again not sure how this would be done.
Thoughts?
Iâm binding the sensor directly to an esphome device using this custom code:
Youâll find all details on how to use it there. The esp device can serve as a bluetooth proxy at the same time.
Ok so I edit the code of a standard Bluetooth proxy and add the miot_mccg02hl code?
Looking at the miot platform I still need the Xiaomi account, right?
What if I donât want to rely on the Xiaomi cloud and stay local?
I just got the sensor this morning and after removing the battery isolator it showed up via the Xiaomi BLE integration. I entered the bind key (obtained via the token_extractor
tool) and it completed.
Out of curiosity I also added the referenced code to ESPHome.
I ended up with the following
Can I confirm the following: