Fix charger wrongly enabled on startup when vehicle connected and minsoc defined (#402)

This commit is contained in:
andig 2020-11-04 10:58:16 +01:00 • committed by GitHub
parent ed12988a64
commit 485e9ee706
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -455,7 +455,7 @@ func (lp *LoadPoint) findActiveVehicle() {
}
}
// updateChargerStatus updates car status and detects car connected/disconnected events
// updateChargerStatus updates charger status and detects car connected/disconnected events
func (lp *LoadPoint) updateChargerStatus() error {
status, err := lp.handler.Status()
if err != nil {
@ -705,10 +705,6 @@ func (lp *LoadPoint) Update(sitePower float64) {
// update progress and soc before status is updated
lp.publishChargeProgress()
// update active vehicle and publish soc
lp.findActiveVehicle()
lp.publishSoC()
// read and publish status
if err := lp.updateChargerStatus(); err != nil {
lp.log.ERROR.Printf("charge controller error: %v", err)
@ -718,6 +714,12 @@ func (lp *LoadPoint) Update(sitePower float64) {
lp.publish("connected", lp.connected())
lp.publish("charging", lp.charging)
// update active vehicle and publish soc
// must be run after updating charger status to make sure
// initial update of connected state matches charger status
lp.findActiveVehicle()
lp.publishSoC()
// sync settings with charger
if lp.status != api.StatusA {
lp.handler.SyncEnabled()

View file

@ -196,6 +196,8 @@ func (site *Site) DumpConfig() {
lp.log.INFO.Println(" charger config:")
logMeter(lp.log, charger)
lp.log.INFO.Printf(" timer %s", presence[timer])
lp.log.INFO.Printf(" mode: %s", lp.GetMode())
}
}