Simple OpenMetrics exporter for BLE devices
Project description
blexy
Simple OpenMetrics exporter for BLE devices.
Requirements
- device with BLE compliant transceiver (e.g. RPi 3+)
- Python 3.7+
Running
pip install blexy
blexy --port 8888 --config-file ~/.blexy.yaml
Endpoints
/- returns list of connected devices in JSON format./metrics- returns values read from connected BLE devices in OpenMetrics format.
Config
- Device & server configuration is by default expected to be placed in
./config.yaml. - Custom config file path can be specified via
-c / --config-filecommand line option. portandlog_levelcan be either specified in config file or through command line options (seeblexy -hfor exact option names).
Example config file
Below file will make blexy connect to two Xiaomi temperature / humidity sensors and listen on port 8080:
port: 8080
log_level: info
ble:
devices:
- name: living room sensor
model: LYWSD03MMC
address: xx:xx:xx:xx:xx:xx
- name: bedroom sensor
model: LYWSD03MMC
address: xx:xx:xx:xx:xx:xx
Example output
$ curl localhost:8080/metrics
# TYPE battery_level_percentage gauge
# UNIT battery_level_percentage percentage
battery_level_percentage_gauge{name="living room sensor",model="LYWSD03MMC",manufacturer="Xiaomi",address="xx:xx:xx:xx:xx:xx",interface="0"} 77
battery_level_percentage_gauge{name="bedroom sensor",model="LYWSD03MMC",manufacturer="Xiaomi",address="xx:xx:xx:xx:xx:xx",interface="0"} 88
# TYPE humidity_percentage gauge
# UNIT humidity_percentage percentage
humidity_percentage_gauge{name="living room sensor",model="LYWSD03MMC",manufacturer="Xiaomi",address="xx:xx:xx:xx:xx:xx",interface="0"} 48
humidity_percentage_gauge{name="bedroom sensor",model="LYWSD03MMC",manufacturer="Xiaomi",address="xx:xx:xx:xx:xx:xx",interface="0"} 51
# TYPE temperature_celsius gauge
# UNIT temperature_celsius celsius
temperature_celsius_gauge{name="living room sensor",model="LYWSD03MMC",manufacturer="Xiaomi",address="xx:xx:xx:xx:xx:xx",interface="0"} 22.33
temperature_celsius_gauge{name="bedroom sensor",model="LYWSD03MMC",manufacturer="Xiaomi",address="xx:xx:xx:xx:xx:xx",interface="0"} 25.11
# TYPE voltage_volts gauge
# UNIT voltage_volts volts
voltage_volts_gauge{name="living room sensor",model="LYWSD03MMC",manufacturer="Xiaomi",address="xx:xx:xx:xx:xx:xx",interface="0"} 3.11
voltage_volts_gauge{name="bedroom sensor",model="LYWSD03MMC",manufacturer="Xiaomi",address="xx:xx:xx:xx:xx:xx",interface="0"} 3.03
# EOF
Supported devices
LYWSD03MMC(Xiaomi)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
blexy-0.2.0.tar.gz
(7.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
blexy-0.2.0-py3-none-any.whl
(8.4 kB
view details)
File details
Details for the file blexy-0.2.0.tar.gz.
File metadata
- Download URL: blexy-0.2.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be57670383b42b81b8db26bdf51f205229ad7aeb073031ef0bb4d878c83363d8
|
|
| MD5 |
5bec4ff111a13b5e4e0bc6097e04d426
|
|
| BLAKE2b-256 |
2a665e8a3561b09cf0799e8d45e41e94ec9d2a2b0b4c6a54ed4cdf7eee4c344c
|
File details
Details for the file blexy-0.2.0-py3-none-any.whl.
File metadata
- Download URL: blexy-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31ff06c2df0ce791624c19b1a1e2961ac8879c6552ae804f5f89636eb3a94a33
|
|
| MD5 |
be88e0a331b96ea30c75730d71bcbe2f
|
|
| BLAKE2b-256 |
a21fa359deff71c185876a05096fc0729ed0086c535c0ea1de86f865644472cb
|