Mercedes: fix limit soc panic (#15039)
This commit is contained in:
parent
3d7d58f955
commit
aa2964d36b
1 changed files with 12 additions and 6 deletions
|
|
@ -97,15 +97,21 @@ func (v *API) Status(vin string) (StatusResponse, error) {
|
|||
res.EvInfo.Battery.ChargingStatus = 3
|
||||
}
|
||||
|
||||
if val, ok := message.Attributes["selectedChargeProgram"]; ok {
|
||||
res.EvInfo.Battery.SelectedChargeProgram = int(val.GetIntValue())
|
||||
val := message.Attributes["chargePrograms"].GetChargeProgramsValue()
|
||||
res.EvInfo.Battery.SocLimit = int(val.ChargeProgramParameters[res.EvInfo.Battery.SelectedChargeProgram].GetMaxSoc())
|
||||
if val, ok := message.Attributes["selectedChargeProgram"]; ok && val != nil {
|
||||
selectedChargeProgram := val.GetIntValue()
|
||||
res.EvInfo.Battery.SelectedChargeProgram = int(selectedChargeProgram)
|
||||
|
||||
if cps, ok := message.Attributes["chargePrograms"]; ok && cps != nil {
|
||||
if cpVal := cps.GetChargeProgramsValue(); cpVal != nil && res.EvInfo.Battery.SelectedChargeProgram < len(cpVal.ChargeProgramParameters) {
|
||||
if chargeProgramParam := cpVal.ChargeProgramParameters[res.EvInfo.Battery.SelectedChargeProgram]; chargeProgramParam != nil {
|
||||
res.EvInfo.Battery.SocLimit = int(chargeProgramParam.GetMaxSoc())
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if val, ok := message.Attributes["maxSoc"]; ok {
|
||||
if val, ok := message.Attributes["maxSoc"]; ok && val != nil {
|
||||
res.EvInfo.Battery.SocLimit = int(val.GetIntValue())
|
||||
}
|
||||
}
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue