From 2e1825092ade7d56f3416d343c9e81b9a347ed1b Mon Sep 17 00:00:00 2001 From: andig Date: Mon, 3 Jul 2023 09:33:28 +0200 Subject: [PATCH] Hyundai: fix registration id --- vehicle/bluelink/identity.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/vehicle/bluelink/identity.go b/vehicle/bluelink/identity.go index 580efeb8ae..934bb6d292 100644 --- a/vehicle/bluelink/identity.go +++ b/vehicle/bluelink/identity.go @@ -14,6 +14,7 @@ import ( "github.com/evcc-io/evcc/util/oauth" "github.com/evcc-io/evcc/util/request" "github.com/google/uuid" + "github.com/samber/lo" "golang.org/x/net/publicsuffix" "golang.org/x/oauth2" ) @@ -66,7 +67,7 @@ func (v *Identity) getDeviceID() (string, error) { uuid := uuid.NewString() data := map[string]interface{}{ - "pushRegId": "1", + "pushRegId": lo.RandomString(64, []rune("0123456789ABCDEF")), "pushType": "GCM", "uuid": uuid, } @@ -79,7 +80,7 @@ func (v *Identity) getDeviceID() (string, error) { "Stamp": stamp, } - var resp struct { + var res struct { RetCode string ResMsg struct { DeviceID string @@ -88,10 +89,14 @@ func (v *Identity) getDeviceID() (string, error) { req, err := request.New(http.MethodPost, v.config.URI+DeviceIdURL, request.MarshalJSON(data), headers) if err == nil { - err = v.DoJSON(req, &resp) + err = v.DoJSON(req, &res) + } + + if res.ResMsg.DeviceID == "" { + err = errors.New("deviceid not found") } - return resp.ResMsg.DeviceID, err + return res.ResMsg.DeviceID, err } func (v *Identity) getCookies() (cookieClient *request.Helper, err error) {