diff --git a/pkg/fronius/configure.go b/pkg/fronius/configure.go index a039325..e8f6d06 100644 --- a/pkg/fronius/configure.go +++ b/pkg/fronius/configure.go @@ -98,7 +98,12 @@ func ForceCharge(modbus_ip string, power_prc int16, port ...string) error { } } else if power_prc == 0 { - Setdefaults(modbus_ip, p) + u.Log.Info("percent of charging is <1%, skipping Force Charge and set defaults.") + err = Setdefaults(modbus_ip, p) + if err != nil { + u.Log.Errorln("Error Setting Defaults: %s ", err) + return err + } } else { err = errors.New("percent of charging is negative") u.Log.Errorf("someting goes wrong when force charging, %s", err) diff --git a/pkg/fronius/schedule.go b/pkg/fronius/schedule.go index 0acddfd..4e11fda 100644 --- a/pkg/fronius/schedule.go +++ b/pkg/fronius/schedule.go @@ -30,18 +30,10 @@ func SetFroniusChargeBatteryMode(pw_forecast float64, pw_batt2charge float64, pw } } - if ch_pc != 0 { - err = ForceCharge(fronius_ip, ch_pc, p) - if err != nil { - u.Log.Errorln("Error forcing charge: %s ", err) - return ch_pc, err - } - } else { - err = Setdefaults(fronius_ip, p) - if err != nil { - u.Log.Errorln("Error Setting Defaults: %s ", err) - return ch_pc, err - } + err = ForceCharge(fronius_ip, ch_pc, p) + if err != nil { + u.Log.Errorln("Error forcing charge: %s ", err) + return ch_pc, err } return ch_pc, nil