How to Integrate Xiaomi Mijia BLE Lovelace UI: Complete guide from connectivity to widgets

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.

πŸ“Š What is the Xiaomi Mijia device? BLE You're using it?
Thermohygrometer (LYWSD03MMC etc.)
Motion sensor (RTCGQ02LM)
Opening sensor (MCCGQ02HL)
Smart button (WXKG01LM)
Other

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 modelChipsetMax. Devices.Radio (m)Price (2026)
CC2652P (recommended)TI CC265250+100~3500 β‚½
ESP32-WROOMEspressif ESP3220-3050~1200 β‚½
Asus USB-BT500Realtek RTL8761B10-1520~900 β‚½
Raspberry Pi built-inBroadcom BCM43455-8100 β‚½ (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:

  1. Install. HACS (Home Assistant Community Store), if you have not already done so.Instructions: official documentation.
  2. V HACS Find and install the Passive repository BLE Monitor by custom-components.
  3. 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
  4. 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:

  1. Use it. bind_key from the Mi Home app (find it in logs when connecting).
  2. 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: 300

4.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: live

4.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?
1. Open the card editing mode in Lovelace. 2. Click on the three dots in the upper right corner β†’ "Viewing YAML". 3. Copy all the code and save to a text file with an extension `.yaml`. 4.To recover: Create a new card β†’ "Show the code" β†’ insert the saved YAML.

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 causeDecision
Device not detectable.Randomization MAC-addressUse it. bind_key or model in configuration
Data is updated every 10 times+ minuteStandard survey intervalInstall. periodic_update_interval: 60
Persistent errors BLE scan failedConflict of Bluetooth devicesDisable other gadgets that use Bluetooth
Sensor shows "--"Weak signal or interferenceMove the adapter closer to the device

⚠️ Note: If you upgrade Home Assistant to version 2026.4+ The custom components have stopped working, do it:

  1. Delete the folder. /config/custom_components/ble_monitor.
  2. Reinstall integration through HACS.
  3. 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?
1. In Mi Home, switch the region to China". 2. Find the device in the list and click on three dots. β†’ "Update firmware". 3. Select the version 2.0.6_0039 (integrational). 4. After rolling back, reset the device (hold the button). 10 flash).

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_fan

6.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:

  1. Create a new Google Sheet and publish it as a web application.
  2. Install Google Sheets integration through HACS.
  3. 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 deviceStandard. CR2032Panasonic CR2032With 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:

  1. Remove the battery for 1 minute.
  2. Insert the battery back and immediately press the reset button (usually hidden under the lid).
  3. 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.