Fix measured phases out of sync due to delayed phase switching by charger (#7162)
This commit is contained in:
parent
b0a7eff793
commit
8ae426e4f4
2 changed files with 12 additions and 4 deletions
|
|
@ -625,14 +625,14 @@ func (lp *Loadpoint) syncCharger() {
|
|||
enabled, err := lp.charger.Enabled()
|
||||
if err == nil {
|
||||
if enabled != lp.enabled {
|
||||
if time.Since(lp.guardUpdated) > guardGracePeriod {
|
||||
if lp.guardGracePeriodElapsed() {
|
||||
lp.log.WARN.Printf("charger out of sync: expected %vd, got %vd", status[lp.enabled], status[enabled])
|
||||
}
|
||||
err = lp.charger.Enable(lp.enabled)
|
||||
}
|
||||
|
||||
if !enabled && lp.charging() {
|
||||
if time.Since(lp.guardUpdated) > guardGracePeriod {
|
||||
if lp.guardGracePeriodElapsed() {
|
||||
lp.log.WARN.Println("charger logic error: disabled but charging")
|
||||
}
|
||||
err = lp.charger.Enable(false)
|
||||
|
|
@ -969,7 +969,10 @@ func (lp *Loadpoint) pvScalePhases(availablePower, minCurrent, maxCurrent float6
|
|||
// - https://github.com/evcc-io/evcc/issues/2613
|
||||
measuredPhases := lp.getMeasuredPhases()
|
||||
if phases > 0 && phases < measuredPhases {
|
||||
lp.log.WARN.Printf("ignoring inconsistent phases: %dp < %dp observed active", phases, measuredPhases)
|
||||
if lp.guardGracePeriodElapsed() {
|
||||
lp.log.WARN.Printf("ignoring inconsistent phases: %dp < %dp observed active", phases, measuredPhases)
|
||||
}
|
||||
lp.resetMeasuredPhases()
|
||||
}
|
||||
|
||||
var waiting bool
|
||||
|
|
@ -1410,6 +1413,11 @@ func (lp *Loadpoint) stopWakeUpTimer() {
|
|||
lp.wakeUpTimer.Stop()
|
||||
}
|
||||
|
||||
// pvScalePhases switches phases if necessary and returns if switch occurred
|
||||
func (lp *Loadpoint) guardGracePeriodElapsed() bool {
|
||||
return time.Since(lp.guardUpdated) > guardGracePeriod
|
||||
}
|
||||
|
||||
// Update is the main control function. It reevaluates meters and charger state
|
||||
func (lp *Loadpoint) Update(sitePower float64, autoCharge, batteryBuffered bool) {
|
||||
lp.processTasks()
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func (lp *Loadpoint) activePhases() int {
|
|||
active := min(expect(vehicle), expect(physical), expect(measured))
|
||||
|
||||
// sanity check - we should not assume less active phases than actually measured
|
||||
if measured > 0 && active < measured {
|
||||
if measured > 0 && active < measured && lp.guardGracePeriodElapsed() {
|
||||
lp.log.WARN.Printf("phase mismatch between %dp measured for %dp vehicle and %dp charger", measured, vehicle, physical)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue