Skip to content

Commit

Permalink
Fix humiture sensory name generation
Browse files Browse the repository at this point in the history
Strip the sensor/ from the device topic name, since we're already
prepenting sensor/humiture
  • Loading branch information
daenney committed Jun 30, 2022
1 parent 5959ad5 commit db83e31
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion collectors/environmental.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"math"
"strings"
"time"

"github.com/kelvins/sunrisesunset"
Expand Down Expand Up @@ -277,7 +278,7 @@ func (c *EnvironmentalCollector) Collect(ch chan<- prometheus.Metric) {
for dev, temp := range temperature {
if hum, ok := humidity[dev]; ok {
ch <- prometheus.MustNewConstMetric(c.humiture,
prometheus.GaugeValue, humiture(temp, hum), fmt.Sprintf("sensor/humiture/%s", dev))
prometheus.GaugeValue, humiture(temp, hum), fmt.Sprintf("sensor/humiture/%s", strings.TrimPrefix(dev, "sensor/")))
}
}

Expand Down

0 comments on commit db83e31

Please sign in to comment.