Skip to content

A Golang application for reading data from Xiaomi plant sensors and exporting the data as prometheus metrics

License

Notifications You must be signed in to change notification settings

miekg/miflora-prom

 
 

Repository files navigation

NAME

miflora-prom - generate prometheus metrics from Xiaomi Mi flower care plant sensor

SYNOPSIS

miflora-prom

DESCRIPTION

miflora-prom is a small application that connects to a Xiami Mi flower plant sensor over blue tooth and converts the sensor data into prometheus metrics. If needs a config file in /etc/miflora to operate.

The data retrieved and the prometheus metrics are:

  • battery level, miflora_meta_battery_percentage{name="<alias>"}
  • firmware version, miflora_meta_firmware_version{name="<alias>", version="<version>"}
  • illumination level in Lux, miflora_plant_illumination_lux{name="<alias>"}
  • moisture percentage, miflora_plant_moisture_percentage{name="<alias>"}
  • ground conductivity, miflora_plant_conductivity{name="<alias>"}

When running as a non-root user the following capabilities are needed: 'CAP_NET_RAW' and 'CAP_NET_ADMIN' for miflora-prom to accessing bluetooth and sending packets.

Under Linux, the application uses the mac address to connect to devices; under MacOs the UUID.

Config file

The configuration file contains lines constisting of a LHS <colon> RHS. It defines the MAC addreses or UUIDs of the sensors to be queried and two other variables:

# adapter, defaults to 'default'
adapter: default
# how often to query the sensors
duration: 1h
# the sensor's aliases and their uuid or mac address
myfirstsensor: 422b23155c369dfee0aea210d1a9bc37
mysecondsensor: ...

Acknowledgments

About

A Golang application for reading data from Xiaomi plant sensors and exporting the data as prometheus metrics

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 81.8%
  • Roff 18.2%