Sungrow: fix battery control (#24841)
This commit is contained in:
parent
4a64c65778
commit
5b5f70c0a8
1 changed files with 19 additions and 17 deletions
36
core/site.go
36
core/site.go
|
|
@ -948,23 +948,6 @@ func (site *Site) update(lp updater) {
|
|||
flexiblePower = site.prioritizer.GetChargePowerFlexibility(lp)
|
||||
}
|
||||
|
||||
rate, err := consumption.At(time.Now())
|
||||
if consumption != nil && err != nil {
|
||||
msg := fmt.Sprintf("no matching rate for: %s", time.Now().Format(time.RFC3339))
|
||||
if len(consumption) > 0 {
|
||||
msg += fmt.Sprintf(", %d consumption rates (%s to %s)", len(consumption),
|
||||
consumption[0].Start.Local().Format(time.RFC3339),
|
||||
consumption[len(consumption)-1].End.Local().Format(time.RFC3339),
|
||||
)
|
||||
}
|
||||
|
||||
site.log.WARN.Println("planner:", msg)
|
||||
}
|
||||
|
||||
batteryGridChargeActive := site.batteryGridChargeActive(rate)
|
||||
site.publish(keys.BatteryGridChargeActive, batteryGridChargeActive)
|
||||
site.updateBatteryMode(batteryGridChargeActive, rate)
|
||||
|
||||
if sitePower, batteryBuffered, batteryStart, err := site.sitePower(totalChargePower, flexiblePower); err == nil {
|
||||
// ignore negative pvPower values as that means it is not an energy source but consumption
|
||||
homePower := site.gridPower + max(0, site.pvPower) + site.batteryPower - totalChargePower
|
||||
|
|
@ -998,6 +981,25 @@ func (site *Site) update(lp updater) {
|
|||
site.log.ERROR.Println(err)
|
||||
}
|
||||
|
||||
// smart grid charging
|
||||
rate, err := consumption.At(time.Now())
|
||||
if consumption != nil && err != nil {
|
||||
msg := fmt.Sprintf("no matching rate for: %s", time.Now().Format(time.RFC3339))
|
||||
if len(consumption) > 0 {
|
||||
msg += fmt.Sprintf(", %d consumption rates (%s to %s)", len(consumption),
|
||||
consumption[0].Start.Local().Format(time.RFC3339),
|
||||
consumption[len(consumption)-1].End.Local().Format(time.RFC3339),
|
||||
)
|
||||
}
|
||||
|
||||
site.log.WARN.Println("planner:", msg)
|
||||
}
|
||||
|
||||
// update battery after reading meters to ensure that (modbus) connection is open
|
||||
batteryGridChargeActive := site.batteryGridChargeActive(rate)
|
||||
site.publish(keys.BatteryGridChargeActive, batteryGridChargeActive)
|
||||
site.updateBatteryMode(batteryGridChargeActive, rate)
|
||||
|
||||
site.stats.Update(site)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue