minSocNotReached checks if minimum is configured and not reached. If vehicle is not configured this will always return false
()
| 1079 | // minSocNotReached checks if minimum is configured and not reached. |
| 1080 | // If vehicle is not configured this will always return false |
| 1081 | func (lp *Loadpoint) minSocNotReached() bool { |
| 1082 | v := lp.GetVehicle() |
| 1083 | if v == nil { |
| 1084 | return false |
| 1085 | } |
| 1086 | |
| 1087 | minSoc := vehicle.Settings(lp.log, v).GetMinSoc() |
| 1088 | if minSoc == 0 { |
| 1089 | return false |
| 1090 | } |
| 1091 | |
| 1092 | if lp.vehicleSoc != 0 { |
| 1093 | active := lp.vehicleSoc < float64(minSoc) |
| 1094 | if active { |
| 1095 | lp.log.DEBUG.Printf("forced charging at vehicle soc %.0f%% (< %.0f%% min soc)", lp.vehicleSoc, float64(minSoc)) |
| 1096 | } |
| 1097 | return active |
| 1098 | } |
| 1099 | |
| 1100 | minEnergy := v.Capacity() * float64(minSoc) * 10 / soc.ChargeEfficiency |
| 1101 | return minEnergy > 0 && lp.getChargedEnergy() < minEnergy |
| 1102 | } |
| 1103 | |
| 1104 | // disableUnlessClimater disables the charger unless climate is active |
| 1105 | func (lp *Loadpoint) disableUnlessClimater() error { |