diff --git a/core/loadpoint_api.go b/core/loadpoint_api.go index 5838c9726..3fe7be5ef 100644 --- a/core/loadpoint_api.go +++ b/core/loadpoint_api.go @@ -566,6 +566,11 @@ func (lp *Loadpoint) GetMaxPhaseCurrent() float64 { func (lp *Loadpoint) GetMinCurrent() float64 { lp.RLock() defer lp.RUnlock() + return lp.getMinCurrent() +} + +// getMinCurrent returns the max loadpoint current +func (lp *Loadpoint) getMinCurrent() float64 { return lp.minCurrent } @@ -631,15 +636,15 @@ func (lp *Loadpoint) SetMaxCurrent(current float64) error { // GetMinPower returns the min loadpoint power for a single phase func (lp *Loadpoint) GetMinPower() float64 { - lp.Lock() - defer lp.Unlock() + lp.RLock() + defer lp.RUnlock() return Voltage * lp.effectiveMinCurrent() } // GetMaxPower returns the max loadpoint power taking vehicle capabilities and phase scaling into account func (lp *Loadpoint) GetMaxPower() float64 { - lp.Lock() - defer lp.Unlock() + lp.RLock() + defer lp.RUnlock() return Voltage * lp.effectiveMaxCurrent() * float64(lp.maxActivePhases()) } diff --git a/core/loadpoint_effective.go b/core/loadpoint_effective.go index 393e85149..f64879dfd 100644 --- a/core/loadpoint_effective.go +++ b/core/loadpoint_effective.go @@ -133,7 +133,7 @@ func (lp *Loadpoint) SocBasedPlanning() bool { // effectiveMinCurrent returns the effective min current func (lp *Loadpoint) effectiveMinCurrent() float64 { - lpMin := lp.GetMinCurrent() + lpMin := lp.getMinCurrent() var vehicleMin, chargerMin float64 if v := lp.GetVehicle(); v != nil {