Sensorer, aka "sensors", reads sensor data from MQTT and makes it available for scraping to Prometheus. It's a Hemtjanst exporter.
This package was written with Go 1.14.
go install github.com/hemtjanst/sensorer/cmd/sensorer
git clone github.com/hemtjanst/sensorergo mod download
There are two endpoints:
/metricswhich contains metrics internal to Sensorer, like HTTP request statistics, memory utilisation etc/sensorswith the sensor metrics
Which metrics are exported depends on the features the device announces.
Every exported metric has a label named source which holds the device's
MQTT topic.
currentTemperature: gaugesensors_temperature_celsiuscurrentRelativeHumidity: gaugesensors_humidity_relative_percentcontactSensorState: gaugesensors_contact_statecurrentPower: gaugesensors_power_current_wattscurrentPowerProduced: gaugesensors_power_produced_current_wattsenergyUsed: countersensors_power_total_kwhenergyProduced: countersensors_power_produced_total_kwhcurrentVoltage: gaugesensors_power_current_voltagecurrentAmpere: gaugesensors_power_current_amperebatteryLevel: gaugesensors_battery_level_percentprecipitationgaugesensors_precipitation_mm_per_hourairPressuregaugesensors_air_pressure_hpawindSpeedgaugesensors_wind_speed_meters_per_secondwindDirectiongaugesensors_wind_direction_degreesglobalRadiationgaugesensors_global_radiation_watts_per_square_meter
A time series is computed for humiture, also known as
the "feels like" temperature: sensors_humiture_celsius.
Two time series are computed based on location.lat and location.long,
respectively sensors_sunrise_time_seconds and sensors_sunset_time_seconds.
A third time series, sensors_daylight returns 1 if the current time
is between sunrise and sunset, and 0 otherwise.
A number of options can be passed at startup in order to configure the
behaviour. Most importantly are probably -exporter.listen-address and
-mqtt.address. These let you configure on what host:port combination
the metrics are exported and on what host:port combination the MQTT
broker can be found.
Issue a sensorer -help for all possible options.
Depending on the Prometheus scrape time and how certain contact sensors report in, it's very possible that you would not be able to see something like a door opening and closing in fairly rapid succession reflected in Prometheus. As such you must not rely on this data for the purposes of home security.