boostPower returns the additional power that the loadpoint should draw from the battery
(batteryBoostPower float64)
| 1490 | |
| 1491 | // boostPower returns the additional power that the loadpoint should draw from the battery |
| 1492 | func (lp *Loadpoint) boostPower(batteryBoostPower float64) float64 { |
| 1493 | boost := lp.GetBatteryBoost() |
| 1494 | if boost == boostDisabled { |
| 1495 | return 0 |
| 1496 | } |
| 1497 | |
| 1498 | // push demand to drain battery (at least 100W) |
| 1499 | delta := math.Max(100, math.Abs(lp.site.GetResidualPower())) |
| 1500 | |
| 1501 | if lp.coarseCurrent() { |
| 1502 | // add effective step power to delta to make sure to step up to the next full amp |
| 1503 | // just using lp.EffectiveStepPower() as delta is not enough because this will result |
| 1504 | // in a too low current when there is a bit remaining grid consumption due to the accuracy |
| 1505 | // of the battery controller |
| 1506 | delta += lp.EffectiveStepPower() |
| 1507 | } |
| 1508 | |
| 1509 | // start boosting by setting maximum power |
| 1510 | if boost == boostStart { |
| 1511 | delta = lp.EffectiveMaxPower() |
| 1512 | |
| 1513 | // expire timers |
| 1514 | if lp.hasPhaseSwitching() { |
| 1515 | lp.phaseTimer = elapsed |
| 1516 | } |
| 1517 | lp.pvTimer = elapsed |
| 1518 | |
| 1519 | if lp.charging() { |
| 1520 | lp.setBatteryBoost(boostContinue) |
| 1521 | } |
| 1522 | } |
| 1523 | |
| 1524 | res := batteryBoostPower + delta + lp.site.GetResidualPower() |
| 1525 | lp.log.DEBUG.Printf("pv charge battery boost: %.0fW = -%.0fW battery - %.0fW boost", -res, batteryBoostPower, delta) |
| 1526 | |
| 1527 | return res |
| 1528 | } |
| 1529 | |
| 1530 | // pvMaxCurrent calculates the maximum target current for PV mode |
| 1531 | func (lp *Loadpoint) pvMaxCurrent(mode api.ChargeMode, sitePower, batteryBoostPower float64, batteryBuffered, batteryStart bool) float64 { |
no test coverage detected