Dozens of Xiaomi Mijia devices with Bluetooth Low Energy support (BLE) β thermohygrometer LYWSD03MMC motion-sensor RTCGQ02LM β They can work directly with Home Assistant without any additional hubs, but they can be integrated into the Lovelace interface. UI Often, questions arise: how to set up scans correctly, avoid loss of communication and create informative cards? This article closes all the gaps - from choosing an adapter BLE before fine-tuning automatic scripts.
We will analyze a unique method of stabilizing the connection through the parameter. `periodic_update_interval`, which reduces the delay in updating data with 10+ minute 30 And then we'll show you how to get around the firmware limitations of Xiaomi devices with custom components, and then we'll end up with the code for temperature widgets, humidity charts, and motion notifications, and adaptable to any design.
1 What Xiaomi Mijia devices support BLE Compatible with Home Assistant
Not all Xiaomi gadgets labeled Mijia work according to protocol BLE. Here is a current list of proven models (2026) that can be integrated into Lovelace UI:
- π‘οΈ Climate sensors: LYWSD03MMC (hydraulic), LYWSD02 (screenless), MHO-C401 (greenhouse)
- πͺ Opening sensors: MCCGQ02HL (door-window), SJWS01LM (waterproof)
- π€ Motion sensors: RTCGQ02LM (illuminated), RTCGQ11LM (mini-version)
- π‘ Smart buttons: WXKG01LM (single-button), WXKG12LM (double)
β οΈ Attention: Devices with index _AQARA (for example, WSDCGQ11LM) They use Zigbee, not BLE, and require a Xiaomi Gateway hub or adapter CC2531. Their setting is fundamentally different!
Before buying, check the labeling on the box or in the Mi Home app: Bluetooth icon βοΈ support BLE. Also note the firmware version β devices older than 2021 may require an update via Mi Home before integration.
2. Equipment requirements: which BLE-adapter
For stable scanning of devices Xiaomi Mijia BLE You need an adapter with Bluetooth 5.0 support+ and Nordic chipset nRF52 or CSR8510. Here is a comparison table of tested models:
| Adapter model | Chipset | Max. Devices. | Radio (m) | Price (2026) |
|---|---|---|---|---|
| CC2652P (recommended) | TI CC2652 | 50+ | 100 | ~3500 β½ |
| ESP32-WROOM | Espressif ESP32 | 20-30 | 50 | ~1200 β½ |
| Asus USB-BT500 | Realtek RTL8761B | 10-15 | 20 | ~900 β½ |
| Raspberry Pi built-in | Broadcom BCM4345 | 5-8 | 10 | 0 β½ (if you already have) |
πΉ Critical nuances:
- π Adapters to CSR4.0 (Cheap Chinese Nano Modules are not compatible with Home Assistant due to lack of HCI support.
- πΆ For houses of size >100 m2 will require multiple adapters with overlapping coverage areas.
If you are using Home Assistant OS on a virtual machine (e.g., Proxmox or VMware), transmission USB-The adapter to the guest system must be configured through PCI Passthrough, otherwise scanned. BLE no-one will work!
π‘
Before buying an adapter, check its compatibility with your version of Home Assistant via the hciconfig command. -a If the adapter doesn't show up, you'll need additional drivers.
3. Set up Home Assistant to work with Xiaomi BLE
Integration of Xiaomi Mijia devices BLE It is implemented through the official component ble_monitor custom-made passive_ble_monitor (It's recommended for stability. Here's a step-by-step guide:
- Install. HACS (Home Assistant Community Store), if you have not already done so.Instructions: official documentation.
- V HACS Find and install the Passive repository BLE Monitor by custom-components.
- Add the following code to the configuration.yaml file (replace) hci0 on your adapter): ble_monitor: bt_interface: 'hci0' devices: - mac: 'XX:XX:XX:XX:XX:XX' # MAC-address of your device restore_state: true periodic_update_interval: 60 # Update every time 60 seconds
- Reboot Home Assistant and check the error log through Settings β Magazines.
β οΈ Attention: MAC-Addresses of Xiaomi Mijia devices BLE They change with each switch on (randomization to save energy) to get around it:
- Use it. bind_key from the Mi Home app (find it in logs when connecting).
- Or tune in. passive_ble_monitor Scanning by model identifier (e.g. model: "LYWSD03MMC").
Is it connected? BLE-adapter USB 2.0 (not 3.0) port?|Are other Bluetooth devices disabled (earphones, keyboards)?|Is the package installed? `bluez` system-wide (checking: `sudo apt list --installed | grep bluez`)?|Is Discoverable on Xiaomi devices enabled (hold the button) 5 flash)?-->
4.Creating Lovelace cards UI for Xiaomi Mijia BLE
Interface Lovelace UI It allows you to visualize sensor data in the form of graphs, icons or text bars. Here are 3 ready-made examples of code to insert into Settings. β Lovelace β Edit:
4.1 Thermohygrometer card with history
type: vertical-stack
cards:
- type: glance
entities:
- entity: sensor.lywsd03mmc_temperature
name: Temperature
- entity: sensor.lywsd03mmc_humidity
name: Humidity
title: Bedroom
- type: history-graph
entities:
- entity: sensor.lywsd03mmc_temperature
- entity: sensor.lywsd03mmc_humidity
hours_to_show: 24
refresh_interval: 3004.2 Notification of movement with photo
type: picture-glance
image: 'https://your-ip-address:8123/local/camera/snapshot.jpg'
entities:
- entity: binary_sensor.rtcgq02lm_motion
name: Movement
icon: 'mdi:motion-sensor'
title: The hallway
camera_view: live4.3 The control panel of the button Xiaomi
type: entities
entities:
- entity: sensor.wxkg01lm_action
name: Last action
- entity: input_boolean.virtual_switch
name: Virtual switch
icon: 'mdi:light-switch'
show_header_toggle: falseπ§ Additional settings:
- π¨ To change icons, use the Material Design Icons library (insert the icon code in the icon field).
- π To keep the schedules updated more often, reduce refresh_interval before 60 Seconds (but this will increase the system load).
- π To hide sensitive data (e.g. sensors in a nursery), use visibility: '[{"condition": "state", "entity": "input_boolean.hide_sensors", "state": "off"}]'.
How to export a ready-made backup card?
5. Solving typical connection problems
Even with the right setup of the Xiaomi Mijia device BLE They can get lost or they can get data late:
| Problem. | Possible cause | Decision |
|---|---|---|
| Device not detectable. | Randomization MAC-address | Use it. bind_key or model in configuration |
| Data is updated every 10 times+ minute | Standard survey interval | Install. periodic_update_interval: 60 |
| Persistent errors BLE scan failed | Conflict of Bluetooth devices | Disable other gadgets that use Bluetooth |
| Sensor shows "--" | Weak signal or interference | Move the adapter closer to the device |
β οΈ Note: If you upgrade Home Assistant to version 2026.4+ The custom components have stopped working, do it:
- Delete the folder. /config/custom_components/ble_monitor.
- Reinstall integration through HACS.
- Update the configuration according to the official calendar.
For devices LYWSD03MMC Firmware until 2022 may require a rollback version via Mi Home (China Mainland region:
How to roll back firmware on LYWSD03MMC?
6. Automation based on sensor data
Collected data from Xiaomi Mijia BLE You can use it to create scripts in Home Assistant:
Smart humidity ventilation
alias: "Ventiling at high humidity"
trigger:
- platform: numeric_state
entity_id: sensor.lywsd03mmc_humidity
above: 65
action:
- service: switch.turn_on
entity_id: switch.ventilation_fan
- delay: "00:30:00"
- service: switch.turn_off
entity_id: switch.ventilation_fan6.2 Traffic alert during prohibited times
Alias: "Security: Movement at Night"
trigger:
- platform: state
entity_id: binary_sensor.rtcgq02lm_motion
to: "on"
condition:
- condition: time
after: "23:00:00"
before: "06:00:00"
action:
- service: notify.telegram_bot
data:
message: "Verging traffic detected in the hallway! {{now().strftime('%H:%M') }}"6.3 Temperature Logic in Google Sheets
This will require:
- Create a new Google Sheet and publish it as a web application.
- Install Google Sheets integration through HACS.
- Add automation:
Alias: "The temperature log in Google Sheets"
trigger:
- platform: time_pattern
minutes: "/30"
action:
- service: google_sheets.append_spreadsheet
data:
spreadsheet_id: "your -id-document"
range: "List1!A:B"
values: >
{{ [now().strftime("%d.%m.%Y %H:%M"), states('sensor.lywsd03mmc_temperature')] }}π Important: For notifications via Telegram, pre-configure the bot in configuration.yaml:
telegram_bot:
- platform: polling
api_key: "your -api- key"
allowed_chat_ids:
- yours.-chat-id
notify:
- name: telegram_bot
platform: telegram
chat_id: Yours -chat-idπ‘
Use the for: trigger condition to avoid false positives, such as for: "00:00:30" for a script to wait 30 seconds before execution, which will eliminate the reaction to short-term humidity spikes or random movements.
7. Optimization of energy consumption and stability
Devices Xiaomi Mijia BLE They're known for falling asleep, because they stop responding to battery-saving questions:
- π Replace the standard batteries CR2032 Panasonic CR2032 or Duracell DL2032 β They keep the charge 30% longer.
- β‘ In the settings passive_ble_monitor set up active_scan: True (increases adapter consumption but stabilizes connection).
- π Once a week force the device to "wake up" by sending a command. ble_write via Node-RED or script:
service: ble_monitor.write
data:
mac: "XX:XX:XX:XX:XX:XX"
service_uuid: "0000fee9-0000-1000-8000-00805f9b34fb"
characteristic_uuid: "0000ffd5-0000-1000-8000-00805f9b34fb"
value: [0xAA, 0x55]π Comparison of battery life:
| The device | Standard. CR2032 | Panasonic CR2032 | With active scans. |
|---|---|---|---|
| LYWSD03MMC | ~6 months | ~9 months | ~4 months |
| RTCGQ02LM | ~12 months | ~18 months | ~8 months |
| MCCGQ02HL | ~24 months | ~36 months | ~18 months |
β οΈ Warning: If the device stopped responding even after the battery was replaced, try resetting it before factory settings:
- Remove the battery for 1 minute.
- Insert the battery back and immediately press the reset button (usually hidden under the lid).
- Hold the button. 10-15 seconds before flashing the indicator.
8. Alternative methods of integration (if the BLE wrong)
If your Xiaomi Mijia devices donβt support you BLE or you are facing unsolvable connection problems, consider these options:
- π Cloud Integration with Mi Home: Install Component xiaomi_miot Get access token via Mi Account Token Extractor. Add to configuration.yaml: xiaomi_miot: username: "your"-email@xiaomi.com" password: "your password" devices: - id: 123456789 # ID Devices from Mi Home Token: "your token"
- π‘ Zigbee Local Bridge: For Aqara devices (e.g, WSDCGQ11LM) Use an adapter CC2531 or ConBee II integrationally Zigbee2MQTT.
- π ESPHome + BLE Proxy: Sweeve cheap modules ESP32 use ESPHome firmware and use them as proxy servers for remote sensors.