Xiaomi Mi Sensors
Integration Key: xiaomiMi
WARNING
Using this together with Bluetooth Low Energy requires that the hciDeviceId settings of both integrations are the same value.
The Xiaomi Mi integration scans for Bluetooth Low Engery (BLE) advertisements from a variety of Xiaomi sensors. Sensor readings can then be published to MQTT using the Home Assistant integration.
Requirements
This integration has all the same requirements as the Bluetooth Low Energy integration.
Supported devices
This integration has been tested with these devices:
LYWSD02
(rectangular body, E-Ink with clock display. broadcasts temperature and humidity when it changes)
LYWSD02
(rectangular body, E-Ink, broadcasts temperature and humidity, about 20 readings per minute, no battery info)
LYWSDCGQ
(circular body, segment LCD, broadcasts temperature and humidity when it changes and battery level periodically)
LYWSD03MMC
(small square body, segment LCD, broadcasts temperature and humidity once in about 10 minutes and battery level once in an hour, advertisements are encrypted, therefore you need to set the key in your configuration, see for instructions the bindKey option)
Mi Flora
(plant sensor, requires up-to-date firmware, tested with v3.2.2)
Settings
Name | Type | Default | Description |
---|---|---|---|
sensors | Sensor options | An array of sensor definitions. | |
hciDeviceId | Number | 0 | Bluetooth Device ID (e.g. 0 to use hci0 ). |
enableMifloraBattery | Boolean | false | Whether to poll for the battery state of all configured MiFlora devices or not. Requires room-assistant to connect to your MiFlora device. |
Sensor Options
Name | Type | Default | Description |
---|---|---|---|
name | String | A human readable name for the sensor. Will be used in MQTT topics. | |
address | String | MAC address of the device (Format). | |
bindKey | String | A decryption key for sensors which send encrypted data. | |
enableMifloraBattery | Boolean | Whether to poll for the battery state of this MiFlora device or not. Requires room-assistant to connect to the device. Overrides the global option if set. |
Address Format
The address
field is a lowercase MAC address without :
. This is the same format as a tag ID in the BLE integration. The BLE integration can also be used to log device IDs to the console.
Encryption
Some Xiaomi sensors encrypted their data (e.g. LYWSD03MMC). To be able to read the data from this sensor one needs to get a hold of the encryption key. For ways to get this key please read this this FAQ entry from the custom-components/sensor.mitemp_bt repository. Once found, it can be set with the bindKey option.
Retrieving keys from the Xiaomi Mijia LYWSD03MMC
- Keep the Xiaomi Mijia LYWSD03MMC sensor close to the mobile phone.
- Make sure that the Bluetooth connection is enabled on the mobile phone.
- Using the mobile phone's browser, navigate to https://atc1441.github.io/TelinkFlasher.html.
- Enlarge the mobile phone's screen for better readability.
- Now, click the [Connect] button and wait until it shows "Connected." See the Log section at the bottom.
- Once connected, click the [Do Activation] button and wait until the "Mi Bind Key" shows the information.
Example Config
global:
integrations:
- xiaomiMi
xiaomiMi:
hciDeviceId: 0
sensors:
- name: xiaomiSensor1
address: c47c8d6c9820
See also
There are many projects dedicated to these devices. This integration has particularly benefited from these two:
- Homebridge plugin. Much of the parser code came from this project.
- mitemp_bt. One of the better documented projects with extensive device support.