Loadpoint: allow fine-grained battery boost (#19385)

This commit is contained in:
andig 2025-04-27 14:07:26 +02:00 • committed by GitHub
parent 7cd94aa187
commit 153b1b61b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 8 deletions

View file

@ -20,6 +20,7 @@ import (
"github.com/evcc-io/evcc/core/planner"
"github.com/evcc-io/evcc/core/session"
"github.com/evcc-io/evcc/core/settings"
"github.com/evcc-io/evcc/core/site"
"github.com/evcc-io/evcc/core/soc"
"github.com/evcc-io/evcc/core/vehicle"
"github.com/evcc-io/evcc/core/wrapper"
@ -74,8 +75,9 @@ type Task = func()
// Loadpoint is responsible for controlling charge depending on
// Soc needs and power availability.
type Loadpoint struct {
clock clock.Clock // mockable time
bus evbus.Bus // event bus
clock clock.Clock // mockable time
bus evbus.Bus // event bus
site site.API
pushChan chan<- push.Event // notifications
uiChan chan<- util.Param // client push messages
lpChan chan<- *Loadpoint // update requests
@ -588,7 +590,8 @@ func (lp *Loadpoint) defaultMode() {
}
// Prepare loadpoint configuration by adding missing helper elements
func (lp *Loadpoint) Prepare(uiChan chan<- util.Param, pushChan chan<- push.Event, lpChan chan<- *Loadpoint) {
func (lp *Loadpoint) Prepare(site site.API, uiChan chan<- util.Param, pushChan chan<- push.Event, lpChan chan<- *Loadpoint) {
lp.site = site
lp.uiChan = uiChan
lp.pushChan = pushChan
lp.lpChan = lpChan
@ -1325,8 +1328,12 @@ func (lp *Loadpoint) boostPower(batteryBoostPower float64) float64 {
return 0
}
// push demand to drain battery
delta := lp.EffectiveStepPower()
// push demand to drain battery (at least 100W)
delta := math.Max(100, math.Abs(lp.site.GetResidualPower()))
if lp.coarseCurrent() {
delta = math.Max(delta, lp.EffectiveStepPower())
}
// start boosting by setting maximum power
if boost == boostStart {
@ -1341,7 +1348,7 @@ func (lp *Loadpoint) boostPower(batteryBoostPower float64) float64 {
}
}
res := batteryBoostPower + delta
res := batteryBoostPower + delta + lp.site.GetResidualPower()
lp.log.DEBUG.Printf("pv charge battery boost: %.0fW = -%.0fW battery - %.0fW boost", -res, batteryBoostPower, delta)
return res

View file

@ -82,7 +82,7 @@ func attachListeners(t *testing.T, lp *Loadpoint) {
}
uiChan, pushChan, lpChan := createChannels(t)
lp.Prepare(uiChan, pushChan, lpChan)
lp.Prepare(new(Site), uiChan, pushChan, lpChan)
}
func TestNew(t *testing.T) {

View file

@ -1022,7 +1022,7 @@ func (site *Site) Prepare(uiChan chan<- util.Param, pushChan chan<- push.Event)
}
}(id)
lp.Prepare(lpUIChan, lpPushChan, site.lpUpdateChan)
lp.Prepare(site, lpUIChan, lpPushChan, site.lpUpdateChan)
}
}