Tesla: fix nil panic (#13384)
This commit is contained in:
parent
7786965a99
commit
58339df79c
1 changed files with 4 additions and 1 deletions
|
|
@ -31,7 +31,10 @@ func NewController(ro, rw *tesla.Vehicle) *Controller {
|
|||
return float64(v.current), nil
|
||||
}
|
||||
res, err := ro.Data()
|
||||
return float64(res.Response.ChargeState.ChargeAmps), apiError(err)
|
||||
if err != nil {
|
||||
return 0, apiError(err)
|
||||
}
|
||||
return float64(res.Response.ChargeState.ChargeAmps), nil
|
||||
}, time.Minute)
|
||||
|
||||
return v
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue