Tesla: fix nil panic (#13384)

This commit is contained in:
andig 2024-04-10 21:05:59 +02:00 • committed by GitHub
parent 7786965a99
commit 58339df79c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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