Homeassistant - Xiaomi Mijia 2 integrate
Introduction:
My home is currently getting from my window sensors Temperature monitoring, since a window sensor, however, may be poor (even in the opened state) can measure the mean space temperature, I chose every room with another thermometer to provide. Since I need another sensor anyway, I also decided the humidity directly with mesen. My first thought was of course self-construction with an ESP8266 and BME280 sensor, but after a short time Search for the thermometer of Xiaomi – the Xiaomi Mijia 2 – For almost 10€ in Germany per sensor, with Bluetooth LE and approx. 6 months of battery life, there is no self-construction against I have ordered 10 of these sensors and they work great.
Homeassistant “Bluetooth capable”
To use a device with Bluetooth LE support, needed of course you have a matching Bluetooth adapter. In my case, I do not use the built-in Bluetooth adapter of my Mini PC, because this is not compatible with Linux and it is not a community drivers. I have a dementia with Amazon ASUS USB-BT500 Nano Bluetooth Stickbought. This has started with the Bluetooth integration in Homeassistant works and can all sensors in my 70m2 apartment and capture and read the packages. Also walls are not It was a problem if someone had to worry about it.
The stick could easily be plugged into a free USB slot and in Homeassistant under “Settings >Devices & Services > Add integration”. The associated integration means “Bluetooth” and shows when everything is running correctly, directly the available stick or its assignment (for me “ue0”). Alternative can be added manually via configuration.yaml :
Xiaomi Mijia 2 “Activate”
The Xiaomi Mijia 2 sensors send the temperature and other information in encrypted form. What is basically good, because not everyone can capture and evaluate information, interfere and in this case a little since we have to “activate” the devices before integration, and to find the encryption key at the same time. Fortunately there is a simple GitHub tool that you use with your smartphone. The page is: “https://atc1441.github.io/TelinkFlasher.html‘. Call the page best with a smartphone (except your PC) supports Bluetooth LE, then it doesn't matter. You must first connect to the sensor by clicking on “Connect” and clicking on Select sensor. In my case, the devices started with LYW[...]. Once You selected the device, you see a small one on the Mija2 Bluetooth icon as soon as the device is connected and on the website you can read temperature and humidity. As soon as that happens is, you can click on “Do Activation” and get the “Mi Bind Key”, you need this to get the data for Homeassistant decrypt...
Insert sensor in Homeassistant
Finally, the sensor has to be integrated into Homeassistant. For First we add the Xiaomi integration with “Settings > Devices & Services > Add Integration > “Xiaomi BLE”. As soon as you these are added, all sensors found are displayed. ♪ do not want to connect directly to the device, but only automatically wanting to capture offerings sent by the sensor, the integration one last. Adds the sensor, fortunately you immediately further field where you can insert the Bind Key to offer decrypt the values of the sensors. Is the key correct, then the binding is successfull. If you don't have a field entering a key, you must get ca. 5 minutes wait, then you will receive a notification in Homeassistant and then under “Settings > Devices & Services” enter the key.
Result
Back…