Skip to content

Commit

Permalink
Smart: fix status response mapping (#4222)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElinaUrbanovich authored and andig committed Aug 25, 2022
1 parent 1f425e9 commit c92d877
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions vehicle/smart/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ var _ api.ChargeState = (*Provider)(nil)
func (v *Provider) Status() (api.ChargeStatus, error) {
res, err := v.statusG()

switch v := res.PreCond.Data.ChargingStatus.Value; v {
switch v := res.PreCond.Data.ChargingStatus.Status; v {
case 0:
return api.StatusC, err
case 1, 2:
if res.PreCond.Data.ChargingActive.Value {
return api.StatusC, err
}
return api.StatusB, err
case 3:
return api.StatusA, err
Expand Down
1 change: 1 addition & 0 deletions vehicle/smart/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
type StatusResponse struct {
PreCond struct {
Data struct {
ChargingPower FloatValue
ChargingActive BoolValue
ChargingStatus IntValue
} `json:"data"`
Expand Down

0 comments on commit c92d877

Please sign in to comment.