Xiaomi Mijia bluetooth temperature & humidity sensor compatibility

I’m interested in adding temperature and humidity sensors throughout my house. On some places it would be nice to physically see the temperature and humidity on a display without the need for a phone.

When looking for alternatives that are nice enough to be seen I came across the Xiaomi Mijia bluetooth temperature and humidity sensor with bluetooth. A nice walkthrough can be seen here:

My question is whether it is possible to use these with Home-Assistant, I know the regular temperature and humidity sensors of Xiaomi / Aqara are and I will be using some of those (too bad you need a gateway for those).

Has anyone been fiddling with the code that was written for Domoticz to get it working in HA?

Code for Domoticz: GitHub - pFenners/mijia-sensor-domoticz


Good question, I am also interested in this sensor.
I have a few of the small Xiaomi Aqara temp and humidity sensors and they work well, but as Emacee said, the Bluetooth sensor also displays the values in place and that’s better in many cases.

Indeed i’d love to see this device supported too. I have 2 of them (one arrived with a broken screen so i was sent a replacement). Being able to use these in home assistant would be amazing!

I have hacked some basic shell scripts to get the Bluetooth sensor data and feed it into mqtt … which is working very well …

1 Like

Hi @mig, what do you use to read the BT data? would you share your scripts? What about connecting it to the Xiaomi gateway?

@mig Can you please share your config/script and any requirements? thanks buddy !

I used hcitool lescan to find out the correct bt mac adress. My sensors show up as MJ_HT_V1

I run it in a crontab to get updated data every ten minutes.



until [ ${RET} -eq 0 ]; do
    data=$(/usr/bin/timeout 20 /usr/bin/gatttool -b $bt --char-write-req --handle=0x10 -n 0100 --listen | grep "Notification handle" -m 2)
    sleep 5

until [ ${RET} -eq 0 ]; do
    battery=$(/usr/bin/gatttool -b $bt --char-read --handle=0x18 | cut -c 34-35)
    sleep 5

temp=$(echo $data | tail -1 | cut -c 42-54 | xxd -r -p)
humid=$(echo $data | tail -1 | cut -c 64-74 | xxd -r -p)
batt=$(echo "ibase=16; $battery"  | bc)

if [[ "$temp" =~ ^[0-9]+(\.[0-9]+)?$ ]]
/usr/bin/mosquitto_pub -h <ip> -V mqttv311 -u <user> -P <password> -t "homeassistant/xiaomi/$sensor/temp" -m "$temp"

if [[ "$humid" =~ ^[0-9]+(\.[0-9]+)?$ ]]
/usr/bin/mosquitto_pub -h <ip> -V mqttv311 -u <user> -P <password> -t "homeassistant/xiaomi/$sensor/humidity" -m "$humid"

if [[ "$batt" =~ ^[0-9]+(\.[0-9]+)?$ ]]
/usr/bin/mosquitto_pub -h <ip> -V mqttv311 -u <user> -P <password> -t "homeassistant/xiaomi/$sensor/battery" -m "$batt"


thanks buddy!!

by the way a new xiaomi temperature sensor is out here it is :


I dont know if it can be linked to HA as it doesnt state how it operates and connects to the Xiaomi app…

I can see that this version does not have any option of wireless connectivity. Am I correct?

I am of the same opinion as you cannot see any wireless connectivity

Hi, Home Assistant has already the sensor miflora based on the same protocol. It should be straightforward to look difference between https://github.com/pFenners/mijia-sensor-domoticz/blob/master/README.md and https://github.com/Tristan79/miflora and migrate it from Domoticz to Home Assistant…

Hi mig,

How I can run this code ?

check out my implementation https://github.com/dolezsa/Xiaomi_Hygrothermo
suggestions are welcome.


Hi, I also created my implementation, that looks similar to MiFlora one, with the same parameters. This sensor is going to be used a lot, so somebody should create a Python library like https://github.com/open-homeautomation/miflora and use it in both HomeAssistant and Domoticz…There we will create a “standard”…Maybe this “open-homeautomation” guy should host it…I will write to him…

1 Like

Hi flavio20002, is there any chance to share your implementation of MiFlora for the HygroThermo sensor? Can’t get it to work…

Sure! It’s working perfectly with 2 sensors and with Raspberry Pi 3. Look at some graphs on Grafana.


Hi there!

Anyone knows its possible to access data using a Bluetooth gateway (like the Xiaomi bed lamp) instead of connecting directly to the sensor through Bluetooth?


I am running on a QNAP Docker, what other alternatives are there to integrate this?

@dolezsa would it still need a gateway ?
I would really like to use a couple of these, but I understand it needs a bluetooth gateway of some sort.

I don’t feel like buy the xiaomi lamp, is there anything else that can do it, or do I not need it at all (the bluetooth gateway that is)

Thanks for the help !


hi @STVE, all you need is any bluetooth le capable device (in my case, bt usb dongle).