This is a Prometheus metrics exporter for the Aranet4 CO2 sensor. It is written in Python and uses the Prometheus client library
The exporter connects to the sensor over bluetooth and exposes the following metrics:
- aranet4_co2
- aranet4_temperature
- aranet4_pressure
- aranet4_humidity
- aranet4_battery_level
- aranet4_update_interval
- aranet4_since_last_update
-
Set environment variables to configure the exporter:
POLLING_INTERVAL_SECONDS
how often to poll the sensor (default: 5)EXPORTER_PORT
port to expose the metrics on (default: 80)SENSOR_MAC_ADDRESS
MAC address of the sensor to poll. If not set, the exporter will use autodiscovery to find the sensor.
-
Install the dependencies:
pip install -r requirements.txt
-
Run the exporter:
python src/main.py
-
Test the exporter by view the output in a browser:
http://localhost:80
-
Add the exporter to your prometheus config:
scrape_configs: - job_name: co2-monitor static_configs: - targets: - {IP ADDRESS OF EXPORTER}:{EXPORTER_PORT} labels: null job: co2-monitor
OR if you're using Prometheus Operator in Kubernetes, create the following ScrapeConfig CRD:
apiVersion: monitoring.coreos.com/v1alpha1 kind: ScrapeConfig metadata: name: co2-monitor namespace: monitoring labels: release: kube-prometheus-stack spec: staticConfigs: - labels: job: co2-monitor targets: - {IP ADDRESS OF EXPORTER}:{EXPORTER_PORT}
-
Import the Grafana dashboard from
dashboard.json
into your Grafana instance. Choose the Prometheus data source that is configured to scrape the exporter.
-
The exporter uses the pyaranet4 library to communicate with the sensor. Currently there is a bug when specifying a MAC address manually, so until this pr is merged, i've bundled a forked version of the library in this repo with the fix applied. Thanks stinjnstijn!
-
The basic scaffolding of the code for the exporter is based on Thomas Stringer's example. Thanks Thomas!