sensorer

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

Sensorer

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.10 but should work with Go 1.8 onwards.

Installation

  • go install github.com/hemtjanst/sensorer/cmd/sensorer
Development
  • git clone github.com/hemtjanst/sensorer
  • go mod download

Exported 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: gauge sensor_temperature_celsius
  • currentRelativeHumidity: gauge sensor_humidity_relative_percent
  • contactSensorState: gauge sensor_contact_state
  • currentPower: gauge sensor_power_current_watts
  • energyUsed: counter sensor_power_total_kwh
  • currentVoltage: gauge sensor_power_current_voltage
  • currentAmpere: gauge sensor_power_current_ampere
  • batteryLevel: gauge sensor_battery_level_percent

Additionally a time series is exposed for humiture, also known as the "feels like" temperature: sensor_humiture_celsius.

Options

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.

Caveats

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPrometheusMetrics

func NewPrometheusMetrics() *prometheus.Registry

NewPrometheusMetrics returns a Prometheus registry with metrics that instrument the exporter itself

func NewSensorMetrics

func NewSensorMetrics(mg *server.Manager) (*prometheus.Registry, error)

NewSensorMetrics returns a Prometheus registry with sensor related collectors

func NewServer

func NewServer(addr string, mg *server.Manager) (func(context.Context), error)

NewServer starts an HTTP server exposing Prometheus metrics

Types

This section is empty.

Directories

Path Synopsis
cmd
sensorer command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL