Renault: handle missing batteryLevel (#13251)
This commit is contained in:
parent
902be1873d
commit
b72156159c
2 changed files with 8 additions and 5 deletions
|
|
@ -54,7 +54,7 @@ type attributes struct {
|
|||
InstantaneousPower int `json:"instantaneousPower"`
|
||||
RangeHvacOff int `json:"rangeHvacOff"`
|
||||
BatteryAutonomy int `json:"batteryAutonomy"`
|
||||
BatteryLevel int `json:"batteryLevel"`
|
||||
BatteryLevel *int `json:"batteryLevel"`
|
||||
BatteryTemperature int `json:"batteryTemperature"`
|
||||
PlugStatus int `json:"plugStatus"`
|
||||
LastUpdateTime string `json:"lastUpdateTime"`
|
||||
|
|
|
|||
|
|
@ -55,12 +55,15 @@ var _ api.Battery = (*Provider)(nil)
|
|||
// Soc implements the api.Vehicle interface
|
||||
func (v *Provider) Soc() (float64, error) {
|
||||
res, err := v.batteryG()
|
||||
|
||||
if err == nil {
|
||||
return float64(res.Data.Attributes.BatteryLevel), nil
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return 0, err
|
||||
if res.Data.Attributes.BatteryLevel == nil {
|
||||
return 0, api.ErrNotAvailable
|
||||
}
|
||||
|
||||
return float64(*res.Data.Attributes.BatteryLevel), nil
|
||||
}
|
||||
|
||||
var _ api.ChargeState = (*Provider)(nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue