Skip to content

Commit

Permalink
Skip collecting supplied heat info on L2A controllers
Browse files Browse the repository at this point in the history
Heat pump controllers of type L2A don't report the amount of
supplied heat (issue #11).

Signed-off-by: Michael Hanselmann <[email protected]>
  • Loading branch information
hansmi committed Sep 24, 2022
1 parent 01beff5 commit f3f6dae
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 2 deletions.
14 changes: 12 additions & 2 deletions luxws-exporter/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
}

Expand Down
90 changes: 90 additions & 0 deletions luxws-exporter/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
`,
},
} {
Expand Down

0 comments on commit f3f6dae

Please sign in to comment.