Added charging state

This commit is contained in:
Andreas Linde 2021-03-21 12:04:26 +01:00
parent 8008611c22
commit bbb3d940f8
No known key found for this signature in database
GPG key ID: 96178502495847D9

View file

@ -333,6 +333,26 @@ func (v *Porsche) SoC() (float64, error) {
return 0, err
}
// Status implements the VehicleStatus interface
func (v *Porsche) Status() (api.ChargeStatus, error) {
res, err := v.chargerG()
if res, ok := res.(porscheEmobilityResponse); err == nil && ok {
switch res.BatteryChargeStatus.PlugState {
case "DISCONNECTED":
return api.StatusA, nil
case "CONNECTED":
switch res.BatteryChargeStatus.ChargingState {
case "OFF", "COMPLETED":
return api.StatusB, nil
case "ON":
return api.StatusC, nil
}
}
}
return api.StatusNone, err
}
// Range implements the api.VehicleRange interface
func (v *Porsche) Range() (int64, error) {
res, err := v.chargerG()