Volvo: fix connection status (#22930)
This commit is contained in:
parent
25e490b7b5
commit
094e27868d
2 changed files with 10 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package connected
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/evcc-io/evcc/api"
|
||||
|
|
@ -34,25 +35,25 @@ func (v *Provider) Soc() (float64, error) {
|
|||
|
||||
// Range implements the api.ChargeState interface
|
||||
func (v *Provider) Status() (api.ChargeStatus, error) {
|
||||
status := api.StatusA // disconnected
|
||||
|
||||
res, err := v.statusG()
|
||||
if err != nil {
|
||||
return status, nil
|
||||
return api.StatusNone, err
|
||||
}
|
||||
|
||||
switch res.ChargingConnectionStatus.Value {
|
||||
case "DISCONNECTED":
|
||||
status = api.StatusA
|
||||
case "CONNECTED", "FAULT":
|
||||
status := api.StatusA // disconnected
|
||||
|
||||
switch s := res.ChargerConnectionStatus.Value; s {
|
||||
case "CONNECTED":
|
||||
status = api.StatusB
|
||||
case "FAULT":
|
||||
return status, fmt.Errorf("invalid status: %s", s)
|
||||
}
|
||||
|
||||
if res.ChargingStatus.Value == "CHARGING" {
|
||||
status = api.StatusC
|
||||
}
|
||||
|
||||
return status, err
|
||||
return status, nil
|
||||
}
|
||||
|
||||
var _ api.VehicleRange = (*Provider)(nil)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ type EnergyState struct {
|
|||
Unit string
|
||||
Timestamp time.Time
|
||||
}
|
||||
ChargingConnectionStatus struct {
|
||||
ChargerConnectionStatus struct {
|
||||
Status string
|
||||
Value string
|
||||
Timestamp time.Time
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue