Loadpoint: set internal current to 0 when disabling charger (#15218)

This commit is contained in:
andig 2024-08-03 14:45:52 +02:00 • committed by GitHub
parent faa9d580d3
commit 90af2f2386
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -862,6 +862,11 @@ func (lp *Loadpoint) setLimit(chargeCurrent float64) error {
lp.setAndPublishEnabled(enabled)
lp.chargerSwitched = lp.clock.Now()
// ensure we always re-set current when enabling charger
if !enabled {
lp.chargeCurrent = 0
}
lp.bus.Publish(evChargeCurrent, chargeCurrent)
// start/stop vehicle wake-up timer

View file

@ -448,7 +448,7 @@ func TestDisableAndEnableAtTargetSoc(t *testing.T) {
lp.Update(-5000, false, time.Time{}, false, false, 0, nil, nil)
ctrl.Finish()
t.Log("soc has fallen below target - soc update prevented by timer")
t.Log("soc has risen below target - soc update prevented by timer")
clock.Add(5 * time.Minute)
charger.EXPECT().Status().Return(api.StatusB, nil)
charger.EXPECT().Enabled().Return(lp.enabled, nil)
@ -460,6 +460,7 @@ func TestDisableAndEnableAtTargetSoc(t *testing.T) {
vehicle.EXPECT().Soc().Return(85.0, nil)
charger.EXPECT().Status().Return(api.StatusB, nil)
charger.EXPECT().Enabled().Return(lp.enabled, nil)
charger.EXPECT().MaxCurrent(int64(maxA)).Return(nil)
charger.EXPECT().Enable(true).Return(nil)
lp.Update(-5000, false, time.Time{}, false, false, 0, nil, nil)
ctrl.Finish()