upgrades supporting modules and corrects type mismatch

This commit is contained in:
2023-11-19 12:17:34 -06:00
parent e2f737884c
commit 4258d307cc
6 changed files with 38 additions and 831 deletions

View File

@@ -4,8 +4,7 @@ import (
"log"
"time"
"tplink/internal/tplink"
"github.com/TheSp1der/tplink"
"github.com/prometheus/client_golang/prometheus"
)
@@ -29,8 +28,8 @@ func (cfg *config) gatherMetrics() {
cfg.Prometheus.CurrentMa.With(prometheus.Labels{"device": host}).Set(float64(m.Emeter.GetRealtime.CurrentMa / 1000.0))
cfg.Prometheus.VoltageMv.With(prometheus.Labels{"device": host}).Set(float64(m.Emeter.GetRealtime.VoltageMv / 1000.0))
cfg.Prometheus.PowerMw.With(prometheus.Labels{"device": host}).Set(float64(m.Emeter.GetRealtime.PowerMw / 1000.0))
cfg.Prometheus.TotalWh.With(prometheus.Labels{"device": host}).Add(float64(m.Emeter.GetRealtime.TotalWh - tracker[host]))
tracker[host] = m.Emeter.GetRealtime.TotalWh
cfg.Prometheus.TotalWh.With(prometheus.Labels{"device": host}).Add(float64(float64(m.Emeter.GetRealtime.TotalWh) - tracker[host]))
tracker[host] = float64(m.Emeter.GetRealtime.TotalWh)
}
time.Sleep(time.Duration(time.Second * 15))
}