Skip to content

Commit

Permalink
Loadpoint: fix spurious negative power warning (#13383)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Apr 10, 2024
1 parent 1b81a64 commit 7786965
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ func (lp *Loadpoint) syncCharger() error {
return fmt.Errorf("charger enabled: %w", err)
}

shouldBeConsistent := lp.chargerUpdateCompleted() && lp.phaseSwitchCompleted()
shouldBeConsistent := lp.shouldBeConsistent()

if shouldBeConsistent {
defer func() {
Expand Down Expand Up @@ -1297,7 +1297,8 @@ func (lp *Loadpoint) UpdateChargePower() {

// https://github.com/evcc-io/evcc/issues/2153
// https://github.com/evcc-io/evcc/issues/6986
if lp.chargePower < -20 {
// https://github.com/evcc-io/evcc/issues/13378
if lp.chargePower < -100 && lp.shouldBeConsistent() {
lp.log.WARN.Printf("charge power must not be negative: %.0f", lp.chargePower)
}

Expand Down Expand Up @@ -1526,6 +1527,10 @@ func (lp *Loadpoint) stopWakeUpTimer() {
lp.wakeUpTimer.Stop()
}

func (lp *Loadpoint) shouldBeConsistent() bool {
return lp.chargerUpdateCompleted() && lp.phaseSwitchCompleted()
}

// chargerUpdateCompleted returns true if enable command should be already processed by the charger (so we can try to sync charger and loadpoint)
func (lp *Loadpoint) chargerUpdateCompleted() bool {
return time.Since(lp.chargerSwitched) > chargerSwitchDuration
Expand Down

0 comments on commit 7786965

Please sign in to comment.