mirror of
https://github.com/steinhobelgruen/netatmo-exporter.git
synced 2024-12-12 08:53:55 +00:00
Export Battery status, Wifi and RF signal strength (#4)
This commit is contained in:
parent
1078a7301d
commit
95b0de08dd
26
collector.go
26
collector.go
|
@ -78,6 +78,22 @@ var (
|
|||
"Rain amount in millimeters",
|
||||
varLabels,
|
||||
nil)
|
||||
|
||||
batteryDesc = prometheus.NewDesc(
|
||||
prefix+"battery_percent",
|
||||
"Battery remaining life (10: low)",
|
||||
varLabels,
|
||||
nil)
|
||||
wifiDesc = prometheus.NewDesc(
|
||||
prefix+"wifi_signal_strength",
|
||||
"Wifi signal strength (86: bad, 71: avg, 56: good)",
|
||||
varLabels,
|
||||
nil)
|
||||
rfDesc = prometheus.NewDesc(
|
||||
prefix+"rf_signal_strength",
|
||||
"RF signal strength (90: lowest, 60: highest)",
|
||||
varLabels,
|
||||
nil)
|
||||
)
|
||||
|
||||
type netatmoCollector struct {
|
||||
|
@ -157,6 +173,16 @@ func collectData(ch chan<- prometheus.Metric, device *netatmo.Device, stationNam
|
|||
if data.Rain != nil {
|
||||
sendMetric(ch, rainDesc, prometheus.GaugeValue, float64(*data.Rain), moduleName, stationName)
|
||||
}
|
||||
|
||||
if device.BatteryPercent != nil {
|
||||
sendMetric(ch, batteryDesc, prometheus.GaugeValue, float64(*device.BatteryPercent), moduleName, stationName)
|
||||
}
|
||||
if device.WifiStatus != nil {
|
||||
sendMetric(ch, wifiDesc, prometheus.GaugeValue, float64(*device.WifiStatus), moduleName, stationName)
|
||||
}
|
||||
if device.RFStatus != nil {
|
||||
sendMetric(ch, rfDesc, prometheus.GaugeValue, float64(*device.RFStatus), moduleName, stationName)
|
||||
}
|
||||
}
|
||||
|
||||
func sendMetric(ch chan<- prometheus.Metric, desc *prometheus.Desc, valueType prometheus.ValueType, value float64, moduleName string, stationName string) {
|
||||
|
|
Loading…
Reference in a new issue