Loadpoint: clamp estimator virtual capacity (#26978)

This commit is contained in:
andig 2026-01-25 13:42:54 +01:00 • committed by GitHub
parent 618385701b
commit 2b13eb2668
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View file

@ -111,7 +111,7 @@ func (s *Estimator) Soc(fetchedSoc *float64, chargedEnergy float64) float64 {
// recalculate gradient, wh per soc %
if socDiff > 10 && energyDiff > 0 {
s.energyPerSocStep = energyDiff / socDiff
s.virtualCapacity = s.energyPerSocStep * 100
s.virtualCapacity = max(s.vehicle.Capacity()*1e3, s.energyPerSocStep*100)
s.log.DEBUG.Printf("soc gradient updated: soc: %.1f%%, socDiff: %.1f%%, energyDiff: %.0fWh, energyPerSocStep: %.1fWh, virtualCapacity: %.0fWh", s.vehicleSoc, socDiff, energyDiff, s.energyPerSocStep, s.virtualCapacity)
}

View file

@ -39,7 +39,7 @@ func TestSocEstimation(t *testing.T) {
charger := &chargerStruct{api.NewMockCharger(ctrl), api.NewMockBattery(ctrl)}
// 8.5 kWh user battery capacity is converted to initial value of 10 kWh virtual capacity (at 85% efficiency)
vehicle.EXPECT().Capacity().Return(8.5)
vehicle.EXPECT().Capacity().Return(8.5).AnyTimes()
ce := NewEstimator(util.NewLogger("foo"), charger, vehicle)
@ -66,6 +66,7 @@ func TestSocEstimation(t *testing.T) {
{5001, 50.0, 100.0, 10000},
{0, 20.0, 20.0, 10000},
{1000, 30.0, 30.0, 10000},
{1000, 50.0, 50.0, 8500}, // cap virtual capacity minimum to physical capacity
}
for _, tc := range tc {