Battery control: hold battery during smart charging (#11511)

This commit is contained in:
andig 2024-01-06 11:12:48 +01:00 • committed by GitHub
parent 0705fca00a
commit 0b906727a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View file

@ -807,7 +807,7 @@ func (site *Site) update(lp Updater) {
}
if batMode := site.GetBatteryMode(); site.batteryDischargeControl {
if mode := site.determineBatteryMode(site.Loadpoints()); mode != batMode {
if mode := site.determineBatteryMode(site.Loadpoints(), smartCostActive); mode != batMode {
if err := site.updateBatteryMode(mode); err != nil {
site.log.ERROR.Println("battery mode:", err)
}

View file

@ -30,9 +30,9 @@ func (site *Site) SetBatteryMode(batMode api.BatteryMode) {
}
}
func (site *Site) determineBatteryMode(loadpoints []loadpoint.API) api.BatteryMode {
func (site *Site) determineBatteryMode(loadpoints []loadpoint.API, smartCostActive bool) api.BatteryMode {
for _, lp := range loadpoints {
if lp.GetStatus() == api.StatusC && (lp.GetMode() == api.ModeNow || lp.GetPlanActive()) {
if lp.GetStatus() == api.StatusC && (smartCostActive || lp.GetMode() == api.ModeNow || lp.GetPlanActive()) {
return api.BatteryHold
}
}

View file

@ -44,7 +44,7 @@ func TestDetermineBatteryMode(t *testing.T) {
loadpoints := []loadpoint.API{lp}
mode := s.determineBatteryMode(loadpoints)
mode := s.determineBatteryMode(loadpoints, false)
assert.Equal(t, tc.expBatMode, mode, tc)
}
}