Smart-hello: reject unsupported vehicle platform (#31022)
This commit is contained in:
parent
d1dd7900c5
commit
614ff4ac06
3 changed files with 18 additions and 13 deletions
|
|
@ -51,11 +51,18 @@ func NewSmartHelloFromConfig(other map[string]any) (api.Vehicle, error) {
|
|||
|
||||
api := hello.NewAPI(log, identity)
|
||||
|
||||
cc.VIN, err = ensureVehicle(cc.VIN, api.Vehicles)
|
||||
|
||||
if err == nil {
|
||||
v.Provider = hello.NewProvider(log, api, cc.VIN, cc.Cache)
|
||||
vehicle, err := ensureVehicleEx(cc.VIN, api.Vehicles, func(v hello.Vehicle) (string, error) {
|
||||
return v.VIN, nil
|
||||
})
|
||||
if err != nil {
|
||||
return v, err
|
||||
}
|
||||
|
||||
return v, err
|
||||
if vehicle.ProprietaryPlatform != 0 {
|
||||
return v, fmt.Errorf("unsupported vehicle platform: %s", vehicle.SeriesCodeVs)
|
||||
}
|
||||
|
||||
v.Provider = hello.NewProvider(log, api, vehicle.VIN, cc.Cache)
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import (
|
|||
"github.com/evcc-io/evcc/util"
|
||||
"github.com/evcc-io/evcc/util/request"
|
||||
"github.com/evcc-io/evcc/util/transport"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
// https://github.com/TA2k/ioBroker.smart-eq
|
||||
|
|
@ -85,7 +84,7 @@ func (v *API) request(method, path string, params url.Values, body io.Reader) (*
|
|||
return req, err
|
||||
}
|
||||
|
||||
func (v *API) Vehicles() ([]string, error) {
|
||||
func (v *API) Vehicles() ([]Vehicle, error) {
|
||||
var res struct {
|
||||
Code Int
|
||||
Message string
|
||||
|
|
@ -116,11 +115,7 @@ func (v *API) Vehicles() ([]string, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
vehicles := lo.Map(res.Data.List, func(v Vehicle, _ int) string {
|
||||
return v.VIN
|
||||
})
|
||||
|
||||
return vehicles, err
|
||||
return res.Data.List, err
|
||||
}
|
||||
|
||||
func (v *API) UpdateSession(vin string) error {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,10 @@ type AppToken struct {
|
|||
}
|
||||
|
||||
type Vehicle struct {
|
||||
VIN string
|
||||
VIN string
|
||||
SeriesCodeVs string `json:"seriesCodeVs"` // "HC11" (legacy), "HY11" (newer platform)
|
||||
ModelName string `json:"modelName"` // e.g. "HY11_EUL_Pro+_RWD_000"
|
||||
ProprietaryPlatform Int `json:"proprietaryPlatform"` // 0: legacy tsp backend (supported), 1: newer platform (status endpoint returns 8063)
|
||||
}
|
||||
|
||||
type VehicleStatus struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue