Skip to content

Commit

Permalink
Loadpoint: log specific charger errors (#13097)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Mar 23, 2024
1 parent adf3d40 commit 580788e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions core/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ func (lp *Loadpoint) Prepare(uiChan chan<- util.Param, pushChan chan<- push.Even
_ = lp.setLimit(lp.effectiveMinCurrent())
}
} else {
lp.log.ERROR.Printf("charger: %v", err)
lp.log.ERROR.Printf("charger enabled: %v", err)
}

// allow charger to access loadpoint
Expand All @@ -655,12 +655,15 @@ func (lp *Loadpoint) Prepare(uiChan chan<- util.Param, pushChan chan<- push.Even
func (lp *Loadpoint) syncCharger() error {
enabled, err := lp.charger.Enabled()
if err != nil {
return err
return fmt.Errorf("charger enabled: %w", err)
}

// some chargers (i.E. Easee in some configurations) disable themself to be able to switch phases
if !enabled && lp.enabled && !lp.phaseSwitchCompleted() {
return lp.charger.Enable(true) // enable charger
if err := lp.charger.Enable(true); err != nil {
return fmt.Errorf("charger enable: %w", err)
}
return nil
}

if lp.chargerUpdateCompleted() {
Expand All @@ -675,7 +678,7 @@ func (lp *Loadpoint) syncCharger() error {
enabled = true // treat as enabled when charging
if lp.chargerUpdateCompleted() {
if err := lp.charger.Enable(true); err != nil { // also enable charger to correct internal state
return err
return fmt.Errorf("charger enable: %w", err)
}
lp.elapsePVTimer()
return nil
Expand All @@ -688,7 +691,7 @@ func (lp *Loadpoint) syncCharger() error {
if charger, ok := lp.charger.(api.CurrentGetter); ok && enabled {
current, err := charger.GetMaxCurrent()
if err != nil {
return err
return fmt.Errorf("charger get max current: %w", err)
}

// smallest adjustment most PWM-Controllers can do is: 100%÷256×0,6A = 0.234A
Expand Down Expand Up @@ -903,7 +906,7 @@ func statusEvents(prevStatus, status api.ChargeStatus) []string {
func (lp *Loadpoint) updateChargerStatus() error {
status, err := lp.charger.Status()
if err != nil {
return err
return fmt.Errorf("charger status: %w", err)
}

lp.log.DEBUG.Printf("charger status: %s", status)
Expand Down Expand Up @@ -1524,7 +1527,7 @@ func (lp *Loadpoint) Update(sitePower float64, autoCharge, batteryBuffered, batt

// read and publish status
if err := lp.updateChargerStatus(); err != nil {
lp.log.ERROR.Printf("charger: %v", err)
lp.log.ERROR.Println(err)
return
}

Expand All @@ -1548,7 +1551,7 @@ func (lp *Loadpoint) Update(sitePower float64, autoCharge, batteryBuffered, batt

// sync settings with charger
if err := lp.syncCharger(); err != nil {
lp.log.ERROR.Printf("charger: %v", err)
lp.log.ERROR.Println(err)
return
}

Expand Down

0 comments on commit 580788e

Please sign in to comment.