diff --git a/vehicle/smart-hello.go b/vehicle/smart-hello.go index 114dc274b..6f8e9f62e 100644 --- a/vehicle/smart-hello.go +++ b/vehicle/smart-hello.go @@ -58,9 +58,7 @@ func NewSmartHelloFromConfig(other map[string]any) (api.Vehicle, error) { return v, err } - if vehicle.ProprietaryPlatform != 0 { - return v, fmt.Errorf("unsupported vehicle platform: %s", vehicle.SeriesCodeVs) - } + api.SetSeries(vehicle.SeriesCodeVs) v.Provider = hello.NewProvider(log, api, vehicle.VIN, cc.Cache) diff --git a/vehicle/smart/hello/api.go b/vehicle/smart/hello/api.go index 7c6aa6396..ad8dcb122 100644 --- a/vehicle/smart/hello/api.go +++ b/vehicle/smart/hello/api.go @@ -18,12 +18,14 @@ import ( type API struct { *request.Helper identity *Identity + baseURI string } func NewAPI(log *util.Logger, identity *Identity) *API { v := &API{ Helper: request.NewHelper(log), identity: identity, + baseURI: ApiURI, } v.Client.Transport = &transport.Decorator{ @@ -54,6 +56,14 @@ func NewAPI(log *util.Logger, identity *Identity) *API { return v } +// SetSeries selects the API host for the vehicle's platform. +// Smart #5 (series HY) is served by the V2 host; #1/#3 (HX/HC) use V1. +func (v *API) SetSeries(series string) { + if strings.HasPrefix(series, "HY") { + v.baseURI = ApiURIV2 + } +} + func (v *API) request(method, path string, params url.Values, body io.Reader) (*http.Request, error) { if body != nil { b, err := io.ReadAll(body) @@ -74,7 +84,7 @@ func (v *API) request(method, path string, params url.Values, body io.Reader) (* body.(*bytes.Reader).Seek(0, io.SeekStart) } - uri := fmt.Sprintf("%s/%s?%s", ApiURI, strings.TrimPrefix(path, "/"), params.Encode()) + uri := fmt.Sprintf("%s/%s?%s", v.baseURI, strings.TrimPrefix(path, "/"), params.Encode()) req, err := request.New(method, uri, body, map[string]string{ "x-api-signature-nonce": nonce, "x-signature": sign, @@ -104,6 +114,7 @@ func (v *API) Vehicles() ([]Vehicle, error) { "userId": {userID}, } + // vehicle list is fetched on V1: SetSeries runs only after this call path := "/device-platform/user/vehicle/secure" req, err := v.request(http.MethodGet, path, params, nil) if err != nil { diff --git a/vehicle/smart/hello/const.go b/vehicle/smart/hello/const.go index 9ba093543..21acf5cd7 100644 --- a/vehicle/smart/hello/const.go +++ b/vehicle/smart/hello/const.go @@ -1,8 +1,9 @@ package hello const ( - ApiURI = "https://api.ecloudeu.com" - ApiKey = "3_L94eyQ-wvJhWm7Afp1oBhfTGXZArUfSHHW9p9Pncg513hZELXsxCfMWHrF8f5P5a" + ApiURI = "https://api.ecloudeu.com" // Smart #1/#3 (series HX/HC) + ApiURIV2 = "https://apiv2.ecloudeu.com" // Smart #5 (series HY) + ApiKey = "3_L94eyQ-wvJhWm7Afp1oBhfTGXZArUfSHHW9p9Pncg513hZELXsxCfMWHrF8f5P5a" appID = "SmartAPPEU" operatorCode = "SMART"