Skip to content

Commit

Permalink
myPV: fix power calculation (#18257)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Jan 17, 2025
1 parent a67601c commit 81b3d44
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions charger/mypv.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/core/loadpoint"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/modbus"
"github.com/evcc-io/evcc/util/sponsor"
Expand All @@ -33,6 +34,7 @@ import (
type MyPv struct {
log *util.Logger
conn *modbus.Connection
lp loadpoint.API
power uint32
statusC uint16
enabled bool
Expand Down Expand Up @@ -191,7 +193,13 @@ var _ api.ChargerEx = (*MyPv)(nil)

// MaxCurrentMillis implements the api.ChargerEx interface
func (wb *MyPv) MaxCurrentMillis(current float64) error {
power := uint16(230 * current)
phases := 1
if wb.lp != nil {
if p := wb.lp.GetPhases(); p != 0 {
phases = p
}
}
power := uint16(voltage * current * float64(phases))

err := wb.setPower(power)
if err == nil {
Expand Down Expand Up @@ -237,9 +245,9 @@ func (wb *MyPv) GetLimitSoc() (int64, error) {
return int64(binary.BigEndian.Uint16(b)) / 10, nil
}

var _ api.PhaseDescriber = (*MyPv)(nil)
var _ loadpoint.Controller = (*MyPv)(nil)

// Phases implements the api.PhasesDescriber interface
func (wb *MyPv) Phases() int {
return 1
// LoadpointControl implements loadpoint.Controller
func (wb *MyPv) LoadpointControl(lp loadpoint.API) {
wb.lp = lp
}

0 comments on commit 81b3d44

Please sign in to comment.