myPV: fix power calculation (#18257)
This commit is contained in:
parent
a67601cadd
commit
81b3d44539
1 changed files with 13 additions and 5 deletions
|
|
@ -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"
|
||||
|
|
@ -33,6 +34,7 @@ import (
|
|||
type MyPv struct {
|
||||
log *util.Logger
|
||||
conn *modbus.Connection
|
||||
lp loadpoint.API
|
||||
power uint32
|
||||
statusC uint16
|
||||
enabled bool
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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…
Add table
Add a link
Reference in a new issue