XIAOMI Mijia Bluetooth Thermometer 2 integration

In Crontab → MySensor.sh
MySensor.sh invokes Script LYWSD03MMC.py and this the sendToMQTT.sh Script.

You just have to edit the sendToMQTT.sh Script.

mosquitto_pub -h localhost -t "MiTemperature2/$2/temp" -u openhabian -P <your_password_here>  -i "mibridge" -m "$3"
mosquitto_pub -h <your_mqtt_broker_IP> -t "MiTemperature2/$2/humidity" -u openhabian -P <your_password_here> -i "mibridge" -m "$4"
mosquitto_pub -h <your_mqtt_broker_IP> -t "MiTemperature2/$2/batteryvoltage" -u openhabian -P <your_password_here> -i "mibridge" -m "$5"
mosquitto_pub -h <your_mqtt_broker_IP> -t "MiTemperature2/$2/batterylevel" -u openhabian -P <your_password_here> -i "mibridge" -m "$6"

<your_password_here> = the mqtt broke password, without < >
-u = your username

I have now managed to get the whole thing running, including the link with MQTT Broker. I had to install an MQTT client here because it did not know the commands from the sendTo files.

The only thing that is still strange is the energy consumption. It is currently at 2-3 per cent per day :frowning: . Do you have any idea what this could be? I work in ATC mode and the sensors transmit their values every 8 minutes or when there are changes greater than 0.5C or 5%.
I had understood that the whole thing is more economical with BLE than with the stock firmware.

Many thanks for your great support :slight_smile:

an addition, according to the MQTT logger I always get the values passed to MQTT 2 times. either that is correct or the script runs 2 times or the sensor sends twice.