#ble #bluetooth #homie #mqtt

app mijia-homie

Service to connect to Xiaomi Mijia 2 temperature/humidity sensors over Bluetooth and report their readings to an MQTT broker following the Homie convention

9 releases

0.2.7 Sep 2, 2023
0.2.6 Jan 18, 2023
0.2.5 Jun 15, 2022
0.2.4 Oct 2, 2021
0.1.0 Oct 31, 2020

#266 in Network programming

Download history 8/week @ 2023-08-14 106/week @ 2023-08-21 55/week @ 2023-08-28 14/week @ 2023-09-04 13/week @ 2023-09-11 1/week @ 2023-09-18 3/week @ 2023-09-25 2/week @ 2023-10-02 1/week @ 2023-10-16 6/week @ 2023-10-23 15/week @ 2023-10-30 1/week @ 2023-11-13 12/week @ 2023-11-20 38/week @ 2023-11-27

53 downloads per month


4.5K SLoC

Mijia sensor to Homie bridge

crates.io page

mijia-homie is a service for connecting to Xiaomi Mijia 2 Bluetooth temperature/humidity sensors and publishing their readings to an MQTT broker following the Homie convention.

See the main project readme for more details and background.


It is recommended to install the latest release from our Debian repository:

$ curl -L https://homiers.jfrog.io/artifactory/api/security/keypair/public/repositories/homie-rs | sudo apt-key add -
$ echo "deb https://homiers.jfrog.io/artifactory/homie-rs stable main" | sudo tee /etc/apt/sources.list.d/homie-rs.list
$ sudo apt update && sudo apt install mijia-homie

Alternatively, you may install with cargo install, but that will require some more setup:

$ cargo install mijia-homie


If you have installed the Debian package, the service will be set up with systemd for you already. Otherwise, copy the mijia-homie binary to /usr/bin, copy debian-scripts/mijia-homie.service to /lib/systemd/system, create a mijia-homie user to run as, and create /etc/mijia-homie for configuration files.

There should be two config files under /etc/mijia-homie:

  • mijia-homie.toml contains the main configuration for the service, such as which MQTT broker to connect to and the name and ID of the Homie device. See mijia-homie.example.toml for an example of the settings that are supported.

  • sensor-names.toml contains a map of sensor MAC addresses to human-readable names. Only the sensors listed in this file will be connected to, so you will need to fill it in before mijia-homie does anything useful. Each line should be of the form:


After editing these config files you will need to restart the service:

$ sudo systemctl restart mijia-homie.service

You may find it helpful to watch the logs to see whether it is managing to connect to your sensors:

$ sudo journalctl -u mijia-homie.service --output=cat --follow

Once it is running, try connecting to your MQTT broker with a Homie controller such as HoDD or openHAB to see your sensors.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~746K SLoC