Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

myPV: fix power calculation #18257

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading