diff --git a/shelly/metrics.go b/shelly/metrics.go index a6ffe30..4310a1f 100644 --- a/shelly/metrics.go +++ b/shelly/metrics.go @@ -9,6 +9,10 @@ type Metrics struct { PowerLimit *prometheus.GaugeVec Current *prometheus.GaugeVec CurrentLimit *prometheus.GaugeVec + NeutralCurrent *prometheus.GaugeVec + NeutralIxsum *prometheus.GaugeVec + NeutralMismatch *prometheus.GaugeVec + NeutralValid *prometheus.GaugeVec Voltage *prometheus.GaugeVec VoltageLimit *prometheus.GaugeVec PowerFactor *prometheus.GaugeVec @@ -69,6 +73,34 @@ func NewMetrics(reg *prometheus.Registry) *Metrics { }, lineLabels, ), + NeutralCurrent: prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Name: "shelly_neutral_current_a", + Help: "The neutral current value in this instant.", + }, + deviceLabels, + ), + NeutralIxsum: prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Name: "shelly_neutral_ixsum_a", + Help: "The neutral ixsum value in this instant.", + }, + deviceLabels, + ), + NeutralMismatch: prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Name: "shelly_neutral_mismatch", + Help: "1 if the neutral is mismatched, else 0.", + }, + deviceLabels, + ), + NeutralValid: prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Name: "shelly_neutral_valid", + Help: "1 if the neutral is valid, else 0.", + }, + deviceLabels, + ), Voltage: prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "shelly_voltage_v", @@ -251,6 +283,10 @@ func NewMetrics(reg *prometheus.Registry) *Metrics { m.PowerLimit, m.Current, m.CurrentLimit, + m.NeutralCurrent, + m.NeutralIxsum, + m.NeutralMismatch, + m.NeutralValid, m.Voltage, m.VoltageLimit, m.PowerFactor, diff --git a/shelly_v1/metrics.go b/shelly_v1/metrics.go index aa03784..774bff7 100644 --- a/shelly_v1/metrics.go +++ b/shelly_v1/metrics.go @@ -105,4 +105,12 @@ func (s *ShellyV1) readEmeters(m *shelly.Metrics) { m.TotalReturned.WithLabelValues(labels...).Add(emeter.TotalReturned) m.Voltage.WithLabelValues(labels...).Add(emeter.Voltage) } + + if s.status.EmeterN != nil && s.status.EmeterN.IsValid { + labels := shelly.DeviceLabels(s.Shelly) + m.NeutralCurrent.WithLabelValues(labels...).Set(s.status.EmeterN.Current) + m.NeutralIxsum.WithLabelValues(labels...).Set(s.status.EmeterN.Ixsum) + m.NeutralValid.WithLabelValues(labels...).Set(shelly.BoolToFloat(s.status.EmeterN.IsValid)) + m.NeutralMismatch.WithLabelValues(labels...).Set(shelly.BoolToFloat(s.status.EmeterN.Mismatch)) + } }