ble_monitor icon indicating copy to clipboard operation
ble_monitor copied to clipboard

problem with Qingping CGPR1 motion sensor, motion detection skipped

Open shift-del1 opened this issue 2 years ago • 3 comments

Firmware: Xiaomi (MiBeacon V5 encrypted), timeout is 25 seconds in Mi Home HA: OS 8.1, Core 2022.5.5, integration: 8.6.6

While in Mi Home all motions are detected, in HA some of them are skipped. According to the Mi Home log, the device detects motion, but the HA integration does not transfer this information from the sensor to HA. See one at 9:21:23:

Screenshot_2022-05-27-09-22-31-774_com xiaomi smarthome

The same in HA:

Screenshot_2022-05-27-09-23-09-693_io homeassistant companion android

Can you please check what could be the issue?

shift-del1 avatar May 27 '22 08:05 shift-del1

BLE monitor does not use the information from the Mi Home app/gateway, but uses the information (BLE advertisements) from the sensor directly. If Bluetooth reception on your HA machine is not that good, you could miss some BLE advertisements. This can explain the difference between Mi Home and BLE monitor.

There are two solutions,

  1. Try to improve the Bluetooth reception. Make sure you place your Bluetooth dongle away from Wifi and SSD devices, e.g. with an USB extension cable (preferably with ferrite clamps).
  2. Use an integration that gets its data from the gateway (e.g. https://github.com/AlexxIT/XiaomiGateway3, CGPR1 should be supported)

Ernst79 avatar May 27 '22 08:05 Ernst79

Hell Ernst79, The motion sensor is working in "dual mode", I prefer BLE monitor because of its passive behavior, but I kept Mi Home mode as a backup in case of an issue. HA is running on a NAS, so the USB extension cable is already in place to keep the dongle as far from the NAS as possible.The distance between the dongle and the motion sensor is roughly 30-40cm, so shouldn't be a problem. The integration from AlexxIT is also available, but BT devices are not enabled to be transferred to HA, so gateway only exposes them to Mi Home. Maybe the solution will be to switch to a Zigbee motion sensor, where the timeout is configurable, like the Aqara P1. Anyway, thanks for checking my issue, I appreciate your help and work.

shift-del1 avatar May 27 '22 14:05 shift-del1

Sound like you should have a good reception yes, I agree. The only way to find out if the problem is with BLE monitor is to enable debug logging for BLE monitor in HA and enable report unknown for this MAC address (check the FAQ how to do this) and check the incoming BLE advertisements. Compare the messages from the report unknown function with the incoming "processed" messages, each BLE advertisement should be translated to a "processed" message. With "processed" message, I mean something like {motion: 1, "light": 0, battery: 100, mac: AABBCCAABBCC} etc.

Unfortunately this is some debugging you have to do yourself.

Ernst79 avatar May 27 '22 17:05 Ernst79