Smart: fix status response mapping (#4222)
This commit is contained in:
parent
1f425e913e
commit
c92d8777fd
2 changed files with 5 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
type StatusResponse struct {
|
||||
PreCond struct {
|
||||
Data struct {
|
||||
ChargingPower FloatValue
|
||||
ChargingActive BoolValue
|
||||
ChargingStatus IntValue
|
||||
} `json:"data"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue