From d2cfd690ac025c02fffef0ddd193d73e0bdace76 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Kuester Date: Sat, 1 Sep 2018 21:16:19 +0200 Subject: [PATCH] Update help and README Because there are labels now (eg. 2323=kitchen 3434=piano) --- README.md | 2 +- arduino.go | 5 +++-- arduino_test.go | 5 +++-- main.go | 12 +++++++----- protocol_test.go | 1 + pulse.go | 5 +++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 76ba6d6..04e601f 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ The logs will show all signals that the exporter is able to decode, but nothing ``` 2) Write down all the IDs of sensors you'd like export to Prometheus. -3) Restart the weather station with those IDs (e.g., `./weather-station 2439 2320`) +3) Restart the weather station with those IDs and give each ID a human-readable label (e.g., `./weather-station 2439=kitchen 2320=piano`) ## Dashboards diff --git a/arduino.go b/arduino.go index 3dce1a1..ba76087 100644 --- a/arduino.go +++ b/arduino.go @@ -9,10 +9,11 @@ import ( "os" "context" - "github.com/pkg/errors" - "github.com/spf13/afero" "strings" "sync" + + "github.com/pkg/errors" + "github.com/spf13/afero" ) var ( diff --git a/arduino_test.go b/arduino_test.go index 512cab9..418b789 100644 --- a/arduino_test.go +++ b/arduino_test.go @@ -2,12 +2,13 @@ package main import ( "context" + "strings" + "testing" + "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "strings" - "testing" ) var deviceFile = "/dev/ttyUSB0" diff --git a/main.go b/main.go index 6801ca4..0fcf142 100644 --- a/main.go +++ b/main.go @@ -2,20 +2,22 @@ package main import ( "context" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promhttp" - "gopkg.in/alecthomas/kingpin.v2" "log" "net/http" "strings" + + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promhttp" + "gopkg.in/alecthomas/kingpin.v2" ) var ( device = kingpin.Flag("device", "Arduino connected to USB"). Default("/dev/ttyUSB0").String() - listenAddr = kingpin.Flag("listen-address", "The address to listen on for HTTP requests."). + listenAddr = kingpin.Flag("listen-address", "The address to listen on for HTTP requests"). Default(":8080").String() - ids = kingpin.Arg("ids", "Sensor IDs that will be exported").StringMap() + ids = kingpin.Arg("id=label ...", "List of all sensor IDs (e.g. 1234=kitchen 2353=piano)"+ + " that will be exported to prometheus. Each ID must be given a human-readable label.").StringMap() temperature *prometheus.GaugeVec humidity *prometheus.GaugeVec diff --git a/protocol_test.go b/protocol_test.go index cf8ef87..e434105 100644 --- a/protocol_test.go +++ b/protocol_test.go @@ -2,6 +2,7 @@ package main import ( "testing" + "github.com/stretchr/testify/assert" ) diff --git a/pulse.go b/pulse.go index 55d724c..1be5126 100644 --- a/pulse.go +++ b/pulse.go @@ -6,12 +6,13 @@ package main import ( "fmt" - "github.com/bradfitz/slice" - "github.com/pkg/errors" "math" "sort" "strconv" "strings" + + "github.com/bradfitz/slice" + "github.com/pkg/errors" ) // Signal implements a received 433 MHz signal of compressed raw time series