Skip to content

Commit

Permalink
Feature: Stop reporting metrics from disconnected sensors (temp, humi…
Browse files Browse the repository at this point in the history
…dity, soil humidity)
  • Loading branch information
tedpearson committed Mar 10, 2024
1 parent 4aa5edb commit b1c9e32
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions weather/weather.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,21 @@ func (p *Parser) Parse(values url.Values) {
if values.Has(fmt.Sprintf("temp%df", i)) {
updateGauge(p.temperature.WithLabelValues(p.name, iStr))(parseValue(fmt.Sprintf("temp%df", i)))
updateGauge(p.battery.WithLabelValues(p.name, iStr))(parseValue("batt" + iStr))
} else {
p.battery.DeleteLabelValues(p.name, iStr)
p.temperature.DeleteLabelValues(p.name, iStr)
}
if values.Has("soilhum" + iStr) {
updateGauge(p.humidity.WithLabelValues(p.name, "soil"+iStr))(parseValue("soilhum" + iStr))
updateGauge(p.battery.WithLabelValues(p.name, "soil"+iStr))(parseValue("battsm" + iStr))
} else {
p.humidity.DeleteLabelValues(p.name, "soil"+iStr)
p.battery.DeleteLabelValues(p.name, "soil"+iStr)
}
if values.Has("humidity" + iStr) {
updateGauge(p.humidity.WithLabelValues(p.name, iStr))(parseValue("humidity" + iStr))
} else {
p.humidity.DeleteLabelValues(p.name, iStr)
}
}

Expand Down

0 comments on commit b1c9e32

Please sign in to comment.