diff --git a/main.go b/main.go index 0378f22..324fc20 100644 --- a/main.go +++ b/main.go @@ -142,11 +142,11 @@ func readRegs(vals map[uint16]float64, client modbus.Client, start, qty uint16) } val, err := reg.read(data[(addr-start-1)*2:]) if err != nil { - if errors.Is(err, errSkippableRead) { - log.Printf("Couldn't parse input register data at %d, skipping: %v", addr, err) - continue + if !errors.Is(err, errSkippableRead) { + return fmt.Errorf("parse input register data at %d: %v", addr, err) } - return fmt.Errorf("parse input register data at %d: %v", addr, err) + log.Printf("Couldn't parse input register data at %d, skipping: %v", addr, err) + val = lastValues[addr] } //fmt.Printf("%s: %v %s\n", reg.name, val, reg.unit) vals[addr] = val @@ -171,13 +171,22 @@ func scrape() error { vals := make(map[uint16]float64) start := time.Now() scrapeStart.SetToCurrentTime() - if err := readRegs(vals, client, 5000, 50); err != nil { + if err := readRegs(vals, client, 5001, 24); err != nil { return err } - if err := readRegs(vals, client, 5050, 50); err != nil { + if err := readRegs(vals, client, 5031, 7); err != nil { return err } - if err := readRegs(vals, client, 5100, 50); err != nil { + if err := readRegs(vals, client, 5049, 1); err != nil { + return err + } + if err := readRegs(vals, client, 5083, 18); err != nil { + return err + } + if err := readRegs(vals, client, 5113, 1); err != nil { + return err + } + if err := readRegs(vals, client, 5144, 6); err != nil { return err } diff --git a/sungrow_map.go b/sungrow_map.go index d881e7d..e5e4012 100644 --- a/sungrow_map.go +++ b/sungrow_map.go @@ -54,10 +54,12 @@ var sungrowInputRegs = map[uint16]*register{ 5022: {"phase_a_current", u16req, 0.1, "A"}, 5023: {"phase_b_current", u16opt, 0.1, "A"}, 5024: {"phase_c_current", u16opt, 0.1, "A"}, + 5031: {"output_real_power", u32req, 1, "VA"}, 5033: {"output_reactive_power", s32opt, 1, "VAr"}, 5035: {"power_factor", s16opt, 0.001, ""}, 5036: {"frequency", u16req, 0.1, "Hz"}, + 5049: {"nominal_reactive_power", s16opt, 0.1, "kVA"}, 5083: {"meter_power", s32req, 1, "W"}, @@ -71,6 +73,7 @@ var sungrowInputRegs = map[uint16]*register{ 5099: {"total_import_energy", u32req, 0.1, "kWh"}, 5113: {"daily_running_time", u16req, 1, "m"}, + 5144: {"total_power_yield_2", u32req, 0.1, "kWh"}, 5148: {"frequency_2", frequency2, 0.01, "Hz"}, }