Working with the Xiaomi Mijia BLE temperature sensor in Home Assistant

Warning

This manual is out of date, see the “How to use this manual” section. Working with Xiaomi BLE sensors in Home Assistant

Below is an example of how to connect the Bluetooth temperature and humidity sensor Xiaomi Mijia BLE MJ_HT_V1 (round with display) to a controller with Home Assistant Core installed (see Installing Home Assistant Core in a python virtual environment).

To connect the sensor, you need to determine its MAC address and make changes to the Home Assistant configuration file.

Detecting the MAC address of the sensor

Turn on the sensor and place it near the controller or a short distance with a direct line of sight. Run the utility bluetoothctl and turn on the Bluetooth device scanning mode:

$ bluetoothctl
[bluetooth]# scan on

Information about detected devices will be displayed in the terminal window.

The sensor sends data about every 30 sec and information from the sensor should appear after some time. We are interested in the device with ID MJ_HT_V1:

[NEW] Device 4C:65:A8:D4:5E:BF MJ_HT_V1

This is the sensor you are looking for and its MAC address is 4C:65:A8:D4:5E:BF.

Stop the scanning process:

[bluetooth]# scan off

Output the list of found devices:

[bluetooth]# devices
Device 4C:65:A8:D4:5E:BF MJ_HT_V1

This list should also include the device you are looking for:

Device 4C:65:A8:D4:5E:BF MJ_HT_V1

Exit the utility:

[bluetooth]# exit

Adding a sensor to the Home Assistant

Home Assistant has built-in support for Xiaomi Mijia BLE MJ_HT_V1 sensors with mitemp_bt integration.

The following lines should be added to the configuration file .homeassistant/configuration.yaml:

sensor:
  - platform: mitemp_bt
    mac: "4C:65:A8:D4:5E:BF"
    name: living_room_wall_temp
    force_update: true
    median: 3
    monitored_conditions:
      - temperature
      - humidity
      - battery

Where:

  • mac - The MAC address of the sensor.

  • name - Displayed in Home Assistant sensor name.

  • force_update - Forced to update data from the sensor in Home Assistant even if it does not change.

  • median - Allows you to eliminate errors from the sensor (sudden changes in temperature and humidity values). This example transmits averaged data for 3 counts.

  • monitored_conditions - Parameters that need to be monitored. In this example these are: temperature, humidity and battery power.

Note

After making changes to the configuration file, you must restart the Home Assistant server.