Expose Xiaomi MI Temperature and Humidity Sensor to prometheus
  • Rust 63.2%
  • Nix 36.8%
Find a file
2025-06-02 22:29:46 +02:00
.github/workflows updates 2024-11-17 18:38:13 +01:00
src add module 2024-11-17 19:31:05 +01:00
.envrc updates 2024-11-17 18:38:13 +01:00
.gitignore updates 2024-11-17 18:38:13 +01:00
Cargo.lock updates 2024-11-17 18:38:13 +01:00
Cargo.toml updates 2024-11-17 18:38:13 +01:00
dbus-bluetooth.xml add module 2024-11-17 19:31:05 +01:00
flake.lock flake update 2025-06-02 22:29:44 +02:00
flake.nix flake update 2025-06-02 22:29:44 +02:00
LICENSE-APACHE licence and most basic readme 2020-02-08 14:04:23 +01:00
LICENSE-MIT licence and most basic readme 2020-02-08 14:04:23 +01:00
module.nix fmt 2025-06-02 22:29:46 +02:00
package.nix fmt 2025-06-02 22:29:46 +02:00
README.md fmt 2025-06-02 22:29:46 +02:00

mitemp-prometheus

Expose Xiaomi MI Temperature and Humidity Sensor to prometheus

Usage

Configuration can be done by either a config file or environment variables.

Usage with a config file

Create a config.toml like

[listen]
port = 3030

[names]
"58:2D:34:39:1A:01" = "Sensor 1"
"58:2D:34:39:1A:02" = "Sensor 2"

And tun the binary like

mitemp-prometheus config.toml

Usage with environment variables

Run the binary with the following environment variables

PORT=3030
NAMES="58:2d:34:39:1a:01=Sensor 1,58:2d:34:39:1a:02=Sensor 2"

Querying metrics

The prometheus metrics will be available at localhost:3030/metrics

sensor_battery{name="Sensor 1", mac="58:2d:34:39:1a:01"} 100
sensor_temperature{name="Sensor 1", mac="58:2d:34:39:1a:01"} 15.8
sensor_humidity{name="Sensor 1", mac="58:2d:34:39:1a:01"} 59.2
sensor_battery{name="Sensor 2", mac="58:2d:34:39:1a:02"} 100
sensor_temperature{name="Sensor 2", mac="58:2d:34:39:1a:02"} 16
sensor_humidity{name="Sensor 2", mac="58:2d:34:39:1a:02"} 55.9

License

Licensed under either of

Contribution

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