Use maximum phase current as effective value (#8297)

This commit is contained in:
andig 2023-06-04 10:41:36 +02:00 • committed by GitHub
parent 6a4fed59b0
commit 6c24407eda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -5,6 +5,7 @@ import (
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
"github.com/samber/lo"
"golang.org/x/exp/constraints"
)
var (
@ -46,3 +47,18 @@ func vehicleTitles(vehicles []api.Vehicle) []string {
return v.Title()
})
}
// max of slice values
func max[T constraints.Ordered](s []T) T {
if len(s) == 0 {
var zero T
return zero
}
m := s[0]
for _, v := range s {
if v > m {
m = v
}
}
return m
}

View file

@ -862,7 +862,7 @@ func (lp *Loadpoint) effectiveCurrent() float64 {
// adjust actual current for vehicles like Zoe where it remains below target
if lp.chargeCurrents != nil {
cur := lp.chargeCurrents[0]
cur := max(lp.chargeCurrents)
return math.Min(cur+2.0, lp.chargeCurrent)
}