From f3f6daeffa634e30bded7f75d5725c4269235c43 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Sat, 24 Sep 2022 10:10:54 +0200 Subject: [PATCH] Skip collecting supplied heat info on L2A controllers Heat pump controllers of type L2A don't report the amount of supplied heat (issue #11). Signed-off-by: Michael Hanselmann --- luxws-exporter/collector.go | 14 ++++- luxws-exporter/collector_test.go | 90 ++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 2 deletions(-) diff --git a/luxws-exporter/collector.go b/luxws-exporter/collector.go index f9f9789..03f3b19 100644 --- a/luxws-exporter/collector.go +++ b/luxws-exporter/collector.go @@ -143,7 +143,13 @@ func (c *collector) collectInfo(ch chan<- prometheus.Metric, content *luxwsclien switch item.Name { case c.terms.StatusType: - hpType = append(hpType, normalizeSpace(*item.Value)) + name := normalizeSpace(*item.Value) + + if strings.EqualFold(name, "L2A") { + q.missingSuppliedHeat = true + } + + hpType = append(hpType, name) case c.terms.StatusSoftwareVersion: swVersion = normalizeSpace(*item.Value) case c.terms.StatusOperationMode: @@ -292,7 +298,11 @@ func (c *collector) collectOutputs(ch chan<- prometheus.Metric, content *luxwscl return c.collectMeasurements(ch, c.outputDesc, content, c.terms.NavOutputs) } -func (c *collector) collectSuppliedHeat(ch chan<- prometheus.Metric, content *luxwsclient.ContentRoot, _ *quirks) error { +func (c *collector) collectSuppliedHeat(ch chan<- prometheus.Metric, content *luxwsclient.ContentRoot, q *quirks) error { + if q.missingSuppliedHeat { + return nil + } + return c.collectMeasurements(ch, c.suppliedHeatDesc, content, c.terms.NavHeatQuantity) } diff --git a/luxws-exporter/collector_test.go b/luxws-exporter/collector_test.go index 99344e9..ed9e71f 100644 --- a/luxws-exporter/collector_test.go +++ b/luxws-exporter/collector_test.go @@ -126,6 +126,37 @@ luxws_operational_mode{mode="running"} 1 luxws_heat_quantity{unit="kWh"} 999 `, }, + { + // https://github.com/hansmi/wp2reg-luxws/issues/11 + name: "info L2A model", + fn: c.collectInfo, + input: &luxwsclient.ContentRoot{ + Items: []luxwsclient.ContentItem{ + { + Name: "Anlagenstatus", + Items: []luxwsclient.ContentItem{ + {Name: "Wärmepumpen Typ", Value: luxwsclient.String("l2a")}, + {Name: "Softwarestand", Value: luxwsclient.String("v1.86.2")}, + {Name: "Betriebszustand", Value: luxwsclient.String("----")}, + }, + }, + }, + }, + want: ` +# HELP luxws_info Controller information +# TYPE luxws_info gauge +luxws_info{hptype="l2a",swversion="v1.86.2"} 1 +# HELP luxws_operational_mode Operational mode +# TYPE luxws_operational_mode gauge +luxws_operational_mode{mode="----"} 1 +# HELP luxws_heat_quantity Heat quantity +# TYPE luxws_heat_quantity gauge +luxws_heat_quantity{unit=""} 0 +`, + wantQuirks: quirks{ + missingSuppliedHeat: true, + }, + }, { name: "temperatures empty", fn: c.collectTemperatures, @@ -528,6 +559,65 @@ luxws_supplied_heat{name="",unit=""} 0 # HELP luxws_temperature Sensor temperature # TYPE luxws_temperature gauge luxws_temperature{name="",unit=""} 0 +`, + }, + { + // Heat pump controllers of type L2A don't report the amount of + // supplied heat. + // + // https://github.com/hansmi/wp2reg-luxws/issues/11 + name: "L2A type", + input: &luxwsclient.ContentRoot{ + Items: []luxwsclient.ContentItem{ + {Name: "elapsed times"}, + {Name: "error memory"}, + {Name: "heat quantity"}, + {Name: "information"}, + {Name: "inputs"}, + {Name: "operating hours"}, + {Name: "outputs"}, + {Name: "switch offs"}, + { + Name: "system status", + Items: []luxwsclient.ContentItem{ + {Name: "type of heat pump", Value: luxwsclient.String("aaa")}, + {Name: "type of heat pump", Value: luxwsclient.String("l2a")}, + }, + }, + {Name: "temperatures"}, + }, + }, + want: ` +# HELP luxws_elapsed_duration_seconds Elapsed time +# TYPE luxws_elapsed_duration_seconds gauge +luxws_elapsed_duration_seconds{name=""} 0 +# HELP luxws_heat_quantity Heat quantity +# TYPE luxws_heat_quantity gauge +luxws_heat_quantity{unit=""} 0 +# HELP luxws_info Controller information +# TYPE luxws_info gauge +luxws_info{hptype="aaa, l2a",swversion=""} 1 +# HELP luxws_input Input values +# TYPE luxws_input gauge +luxws_input{name="",unit=""} 0 +# HELP luxws_latest_error Latest error +# TYPE luxws_latest_error gauge +luxws_latest_error{reason=""} 0 +# HELP luxws_latest_switchoff Latest switch-off +# TYPE luxws_latest_switchoff gauge +luxws_latest_switchoff{reason=""} 0 +# HELP luxws_operating_duration_seconds Operating time +# TYPE luxws_operating_duration_seconds gauge +luxws_operating_duration_seconds{name=""} 0 +# HELP luxws_operational_mode Operational mode +# TYPE luxws_operational_mode gauge +luxws_operational_mode{mode=""} 1 +# HELP luxws_output Output values +# TYPE luxws_output gauge +luxws_output{name="",unit=""} 0 +# HELP luxws_temperature Sensor temperature +# TYPE luxws_temperature gauge +luxws_temperature{name="",unit=""} 0 `, }, } {