Optimizer: fix panic on plan overrun (#25227)
This commit is contained in:
parent
f0887f8f5b
commit
88bc112486
1 changed files with 2 additions and 2 deletions
|
|
@ -219,11 +219,11 @@ func (site *Site) optimizerUpdate(battery []measurement) error {
|
|||
|
||||
if ts := lp.EffectivePlanTime(); !ts.IsZero() {
|
||||
// TODO precise slot placement
|
||||
if slot := int(time.Until(ts) / tariff.SlotDuration); slot < minLen {
|
||||
if slot := int(time.Until(ts) / tariff.SlotDuration); slot < minLen && slot >= 0 {
|
||||
bat.SGoal = lo.RepeatBy(minLen, func(_ int) float32 { return 0 })
|
||||
bat.SGoal[slot] = float32(goal)
|
||||
} else {
|
||||
site.log.DEBUG.Printf("plan beyond forecast range: %.1f at %v", goal, ts.Round(time.Minute))
|
||||
site.log.DEBUG.Printf("plan beyond forecast range or overrun: %.1f at %v slot %d", goal, ts.Round(time.Minute), slot)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue