Skip to content

Commit

Permalink
Fix phase detection unstable with estimated power usage
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jan 2, 2022
1 parent 1f1c062 commit 94b8897
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -1196,10 +1196,11 @@ func (lp *LoadPoint) updateChargeCurrents() {
lp.chargeCurrents = nil
phaseMeter, ok := lp.chargeMeter.(api.MeterCurrent)
if !ok {
// guess active phases from power consumption
// assumes that chargePower has been updated before
// Guess active phases from power consumption. Assumes that chargePower has been
// updated before. Discussion in https://github.com/evcc-io/evcc/issues/2146 and
// https://github.com/evcc-io/evcc/issues/2177
if lp.charging() && lp.chargeCurrent > 0 {
phases := int(math.Round(lp.chargePower / Voltage / lp.chargeCurrent))
phases := int(math.Ceil(lp.chargePower/Voltage/lp.chargeCurrent - 0.05))
if phases >= 1 && phases <= 3 {
lp.activePhases = phases
lp.log.DEBUG.Printf("detected phases: %dp (%.1fA @ %.0fW)", lp.activePhases, lp.chargeCurrent, lp.chargePower)
Expand Down

0 comments on commit 94b8897

Please sign in to comment.