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
- 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.
- Open up your CONFIGURATION.YAML file
- 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
- Replace the
mac: xx:xx:xx:xx:xx:xxwith the MAC address of your sensor.
- Save the configuration.
- 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
- Once your raspberry pi reboots you will be able to add the sensors to Lovelace.
Adding the Xiaomi Mijia Temperature Sensor to Lovelace
- Navigate to your home assistant home page, click on the 3 dot menu and click CONFIGURE UI
- Click on ADD
- Select the ENTITIES CARD option
- Add the three sensors using
- Select all three and click save
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.
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!