Reset MinSoC Before Vehicle Change (#4321)
This commit is contained in:
parent
df1e52f41b
commit
48926cfc30
2 changed files with 16 additions and 3 deletions
|
|
@ -817,6 +817,10 @@ func (lp *LoadPoint) setActiveVehicle(vehicle api.Vehicle) {
|
|||
}
|
||||
lp.log.INFO.Printf("vehicle updated: %s -> %s", from, to)
|
||||
|
||||
// reset minSoC and targetSoC before change
|
||||
lp.setMinSoC(0)
|
||||
lp.setTargetSoC(0)
|
||||
|
||||
if lp.vehicle = vehicle; vehicle != nil {
|
||||
lp.socUpdated = time.Time{}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,9 +56,13 @@ func (lp *LoadPoint) GetTargetSoC() int {
|
|||
return lp.SoC.target
|
||||
}
|
||||
|
||||
// setTargetSoC sets loadpoint charge target soc (no mutex)
|
||||
func (lp *LoadPoint) setTargetSoC(soc int) {
|
||||
lp.SoC.target = soc
|
||||
lp.socTimer.SoC = soc
|
||||
// test guard
|
||||
if lp.socTimer != nil {
|
||||
lp.socTimer.SoC = soc
|
||||
}
|
||||
lp.publish("targetSoC", soc)
|
||||
}
|
||||
|
||||
|
|
@ -83,6 +87,12 @@ func (lp *LoadPoint) GetMinSoC() int {
|
|||
return lp.SoC.min
|
||||
}
|
||||
|
||||
// setMinSoC sets loadpoint charge min soc (no mutex)
|
||||
func (lp *LoadPoint) setMinSoC(soc int) {
|
||||
lp.SoC.min = soc
|
||||
lp.publish("minSoC", soc)
|
||||
}
|
||||
|
||||
// SetMinSoC sets loadpoint charge minimum soc
|
||||
func (lp *LoadPoint) SetMinSoC(soc int) {
|
||||
lp.Lock()
|
||||
|
|
@ -92,8 +102,7 @@ func (lp *LoadPoint) SetMinSoC(soc int) {
|
|||
|
||||
// apply immediately
|
||||
if lp.SoC.min != soc {
|
||||
lp.SoC.min = soc
|
||||
lp.publish("minSoC", soc)
|
||||
lp.setMinSoC(soc)
|
||||
lp.requestUpdate()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue