Current Date:17 September, 2021

How to setup a Xiaomi Mijia Temperature Sensor in Home Assistant

I love finding new devices to add to my Home Assistant setup. In this article will walk you through how to setup a Xiaomi Mijia Temperature sensor in Home Assistant. We will then setup the temperature card in Home Assistant with the new sensors.

I’ve been looking to add additional sensors to my Home Assistant setup. I found this cheap deal for a Xiaomi Mijia Temperature Sensor on OzBargain so decided to give it a go.

At the moment I don’t have a smart thermostat like a Nest or any other climate device. I was interested in knowing the temperature and humidity inside our home and to compare it with the outside temperature using the official Australian Bureau of Meteorology Home Assistant temperature sensors. This is more of novelty thing for now until I’m able to upgrade my old mercury thermostat to a smart thermostat to use with Home Assistant.

Let’s get started on setting up the Xiaomi Mijia Temperature Sensor in Home Assistant!

The Xiaomi Mijia Temperature Sensor

In the packaging you get the following:

  • 1 x Xiaomi Mijia Bluetooth Temperature Humidity Sensor
  • 1 x Wall Mount
  • 1 x User Manual

Setting up the Xiaomi Mijia Temperature Sensor in Home Assistant

Setting up the Xiaomi Mijia Temperature Sensor in Home Assistant is pretty straightforward. Pop in a AAA battery in the sensor. I’d recommend not mounting it in its final position as you’ll most likely find yourself having to move it to a suitable place which is within bluetooth range to your Pi.

Configuring Home Assistant

  1. Before we add the configuration for the sensor, we will need to establish what the MAC address is of the sensor. I used my Android 10 phone to pair to the sensor. Once paired, I was able to view my connected devices and get the MAC address of the sensor.
  2. Open up your CONFIGURATION.YAML file
  3. Add the following code to SENSOR
# Xiaomi temp sensor
sensor:
  - platform: mitemp_bt
    mac: 'xx:xx:xx:xx:xx:xx'
    name: Home Temp Sensor
    force_update: true
    median: 1
    monitored_conditions:
      - temperature
      - humidity
      - battery
  1. Replace the mac: xx:xx:xx:xx:xx:xx with the MAC address of your sensor.
  2. Save the configuration.
  3. Now this is the important step. You need to reboot your raspberry pi and not by using the “Restart HASS” option from Configurator. Navigate to HASS.IO from the left hand menu, select SYSTEM and under HOST SYSTEM click on RESTART
  4. Once your raspberry pi reboots you will be able to add the sensors to Lovelace.

Adding the Xiaomi Mijia Temperature Sensor to Lovelace

Temperature and humidity sensor in Home Assistant
Temperature Sensor on Lovelace
  1. Navigate to your home assistant home page, click on the 3 dot menu and click CONFIGURE UI
  2. Click on ADD
  3. Select the ENTITIES CARD option
  4. Add the three sensors using SENSOR.NAMEOFSENSOR
  5. Select all three and click save
How to add sensors to Lovelace

When you add the sensor to lovelace, it will take the name you specified under NAME in your configuration from step 2. You can set your own custom name for each sensor by using the CUSTOMIZATION configuration under the CONFIGURATION menu.

Extra Configuration Options

For more configuration options, see the Xiaomi BLE Temperature and Humidity sensor documentation.

Problem

I have noticed that after a few hours, the temperatures seem to stop being received by Home Assistant. The only way it seems to fix it in the short term is to reboot Home Asssitant. I hope there is a fix on the way!

SUPPORT ME!

If you’d like to support TECHmarC, or if you’re using an adblocker, I ask you to consider whitelisting my website.

The ads displayed on this site help go towards keeping the website alive. I know its a small ask but every little contribution helps! You can also support me by Buying me a Coffee!

 

Buy me a coffeeBuy me a coffee