Use maximum phase current as effective value (#8297)
This commit is contained in:
parent
6a4fed59b0
commit
6c24407eda
2 changed files with 17 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue