Skip to content

Commit

Permalink
Ensure meters are updated even if charger is not available (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed May 11, 2020
1 parent e3b8890 commit e3f02ab
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions core/loadpoint.go
Expand Up @@ -436,6 +436,14 @@ func (lp *LoadPoint) resetGuard() {

// update is the main control function. It reevaluates meters and charger state
func (lp *LoadPoint) update() {
// read and publish meters first
meterErr := lp.updateMeters()

// update ChargeRater here to make sure initial meter update is caught
lp.bus.Publish(evChargeCurrent, lp.targetCurrent)
lp.bus.Publish(evChargePower, lp.chargePower)

// read and publish status
if err := retry.Do(lp.updateChargeStatus, retry.Attempts(3)); err != nil {
log.ERROR.Printf("%s charger error: %v", lp.Name, err)
return
Expand All @@ -445,13 +453,6 @@ func (lp *LoadPoint) update() {
lp.publish("connected", lp.connected())
lp.publish("charging", lp.charging)

// catch any persistent meter update error
meterErr := lp.updateMeters()

// update ChargeRater here to make sure initial meter update is caught
lp.bus.Publish(evChargeCurrent, lp.targetCurrent)
lp.bus.Publish(evChargePower, lp.chargePower)

// check if car connected and ready for charging
var err error

Expand Down

0 comments on commit e3f02ab

Please sign in to comment.