kia_uvo icon indicating copy to clipboard operation
kia_uvo copied to clipboard

Hyundai USA - set charging does nothing

Open FuzzyMistborn opened this issue 2 years ago • 16 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

When i try to use the set climate or charge level services nothing happens.

Describe the solution you'd like A clear and concise description of what you want to happen.

Being able to set the charge and climate levels

Include the logs of the end point from Data in HA if this is a sensor

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

Hyundai USA. Ioniq 5 specifically.

FuzzyMistborn avatar Apr 15 '22 19:04 FuzzyMistborn

Lets focus this issue on setting charge limits as it looks like you have two issues. Charge limits for Hyundai USA currently isn't implemented and doesn't look like others have done this in bluelinky either. To get this working we will need someone to sniff the traffic and reverse engineer it.

As for remote start that should work - ideally open a separate issue and post logs of what is happening when you call the service. It could be that it is different for Evs.

cdnninja avatar Apr 17 '22 01:04 cdnninja

If you have instructions for how to sniff the traffic let me know, happy to do it.

FuzzyMistborn avatar Apr 18 '22 01:04 FuzzyMistborn

This method if it has a website: https://github.com/fuatakgun/kia_uvo/wiki/How-to-sniff-API-via-MS-Edge This method if it doesn't: https://github.com/fuatakgun/kia_uvo/wiki/How-to-reverse-engineer-app-traffic-on-Android-phone

cdnninja avatar Apr 18 '22 22:04 cdnninja

Ok, I have done that (used Firefox but it should be the same data). Which are needed?

image

FuzzyMistborn avatar Apr 19 '22 00:04 FuzzyMistborn

I would think it will be that remoteAction one you have selected. You will need to view the contents of that file. I am not sure exactly how to do that in firefox. It should look something like this code here. The "data" values will be different though since I am linking to start_climate not charging as we don't have a method for charging a USA Hyundai yet. The data values are the key items here, potentially headers but those typically match.

https://github.com/fuatakgun/kia_uvo/blob/35e6ed802051948611d2a9fcd81b76b16d50aa95/custom_components/kia_uvo/HyundaiBlueLinkAPIUSA.py#L353-L376

Someone else got this initial work going for USA Hyundai. It looks like we are using the mobile app API which is different than the website. The data values may be the same but a chance exists that it won't be. So if the values don't look right we may need to move to sniffing the mobile app.

cdnninja avatar Apr 19 '22 16:04 cdnninja

Let me know if you need anything else, copying out what I can:

URL: https://owners.hyundaiusa.com/bin/common/remoteAction

Response Headers:

HTTP/1.1 200 OK
Server: Apache/2.4.51 (IUS) Communique/4.3.2 OpenSSL/1.0.2k-fips
X-Frame-Options: SAMEORIGIN
ADRUM_0: g:b2b918b8-2cd1-4d50-8e12-0fb818bc7bef
ADRUM_1: n:hyundai-prod_a5d7022d-6b0a-4522-9864-8274a3217b4a
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Cache-Control: no-cache
X-XSS-Protection: 1; mode=block
Content-Length: 64
Content-Type: text/html;charset=utf-8
Date: Tue, 19 Apr 2022 23:58:16 GMT
Connection: keep-alive
Strict-Transport-Security: max-age=86400; includeSubDomains

Request Headers

POST /bin/common/remoteAction HTTP/1.1
Host: owners.hyundaiusa.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
CSRF-Token: undefined
Content-Length: 605
Origin: https://owners.hyundaiusa.com
DNT: 1
Connection: keep-alive
Referer: https://owners.hyundaiusa.com/content/myhyundai/us/en/page/blue-link.html
Cookie: OptanonConsent=isIABGlobal=false&datestamp=Mon+Apr+04+2022+12%3A01%3A05+GMT-0400+(Eastern+Daylight+Time)&version=6.30.0&hosts=&consentId=6693cdf6-ebaa-4c65-928d-8aa26a178be8&interactionCount=1&landingPath=NotLandingPage&groups=C0001%3A1%2CC0003%3A1%2CC0002%3A1%2CBG8%3A1%2CC0004%3A1&geolocation=US%3BPA&AwaitingReconsent=false; OptanonAlertBoxClosed=2022-03-31T18:21:22.544Z; LPVID=EwZGVhYTVhOWE0ZTM3ZmI2; AMCV_3C3BCE0154FA24300A4C98A1%40AdobeOrg=-408604571%7CMCIDTS%7C19102%7CMCMID%7C31883741324953227464999190005400849772%7CMCOPTOUT-1650419894s%7CNONE%7CvVersion%7C4.6.0; dtm_token_sc=AQEHetjKq1lYOQENX1vnAQEBAQA; dtm_token=AQEHetjKq1lYOQENX1vnAQEBAQA; LPSID-41916303=YHECWswRR9uuaLiNq3M47A; at_check=true; AMCVS_3C3BCE0154FA24300A4C98A1%40AdobeOrg=1; csrf_token=undefined; jwt_token=JWT-eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJNeUh5dW5kYWkiLCJuYW1lIjoiZ2VvZmZAd2V5bC5tZSIsImlzcyI6Imh0dHBzOi8vb3duZXJzLmh5dW5kYWl1c2EuY29tIiwiZXhwIjoxNjUwNDMwMjMyODcyLCJpYXQiOjE2NTA0MTIyMzI4NzJ9.M6ytfuALWDwS1N1hXgMZGpvintRTNbchDtwvUzSTQ3I; s_name=XXXXX; isValidatedVehicle=false; s_sq=hmahyundaiowners%3D%2526c.%2526a.%2526activitymap.%2526page%253Dblue-link%2526link%253DSubmit%2526region%253DremotePresetValidatePinModal%2526pageIDType%253D1%2526.activitymap%2526.a%2526.c%2526pid%253Dblue-link%2526pidt%253D1%2526oid%253Dfunctiononclick%252528event%252529%25257BSave_Submit_Remote_Preset%252528this%252529%25253Bthis.disabled%25253Dtrue%25253B%25257D%2526oidt%253D2%2526ot%253DSUBMIT; s_cc=true; s_ppv=blue-link%2C30%2C18%2C1238; s_tp=4193; mbox=session#4b65d40c701a4900bc8c2ef27b948b8c#1650414052
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin

And under the "request" tab in Network this is the payload:

vin=XXXXX&username=XXXX&token=JWT-eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJNeUh5dW5kYWkiLCJuYW1lIjoiZ2VvZmZAd2V5bC5tZSIsImlzcyI6Imh0dHBzOi8vb3duZXJzLmh5dW5kYWl1c2EuY29tIiwiZXhwIjoxNjUwNDMwMjMyODcyLCJpYXQiOjE2NTA0MTIyMzI4NzJ9.M6ytfuALWDwS1N1hXgMZGpvintRTNbchDtwvUzSTQ3I&pin=4203&url=https%3A%2F%2Fowners.hyundaiusa.com%2Fcontent%2Fmyhyundai%2Fus%2Fen%2Fpage%2Fblue-link.html&airCtrl=true&igniOnDuration=NaN&airTempvalue=LO&defrost=false&heating1=0&gen=2&regId=H00004152526VKM8KRDAF9NU069614&seatHeaterVentInfo=%7B%22drvSeatHeatState%22%3A%222%22%7D&service=postRemoteFatcStart

FuzzyMistborn avatar Apr 20 '22 00:04 FuzzyMistborn

I believe I'm having the same issue - or at least I'm having the same symptoms.

The integration is able to read data about my 2022 ioniq 5 located in USA fine. But I am unable to send a start climate request. In the HA log it always returns the error:

2022-05-04 11:20:25 DEBUG (SyncWorker_4) [custom_components.kia_uvo.HyundaiBlueLinkAPIUSA] kia_uvo - Start engine response: {"errorSubCode":"GEN","systemName":"BLODS","errorSubMessage":"Feature Status is OFF","errorMessage":"Your vehicle does not support this feature.","errorCode":502}

I've tried a variety of different combinations of settings in the dev tools services, including turning on nothing at all, just setting a duration, just setting a temp, etc - always the same error.

I created a request from the website and grabbed the request data payload:

vin	"XXXXXXXXXXXXX"
username	"[email protected]"
token	"JWT-eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJNeUh5dW5kYWkiLCJuYW1lIjoiZXJpY0BoYW5zZW4ub3JnIiwiaXNzIjoiaHR0cHM6Ly9vd25lcnMuaHl1bmRhaXVzYS5jb20iLCJleHAiOjE2NTE2OTU4MzkxNzEsImlhdCI6MTY1MTY3NzgzOTE3MX0.zVDZ9KyAh6SI-Gn1zax_Uz3ARPmoXOJsCyzl1NDcYF0"
pin	"XXXX"
url	"https://owners.hyundaiusa.com/content/myhyundai/us/en/page/dashboard.html"
airCtrl	"true"
igniOnDuration	"NaN"
airTempvalue	"69"
defrost	"false"
heating1	"3"
gen	"2"
regId	"H00004213189VKM8KRDAF9NU081214"
seatHeaterVentInfo	"{\"drvSeatHeatState\":\"2\"}"
service	"postRemoteFatcStart"

I think that's the info you're missing? Unfortunately I have no experience with mobile app work so I have no idea where to start on sniffing the mobile app.

semibreve42 avatar May 04 '22 15:05 semibreve42

Let me know if you need anything else, copying out what I can:

URL: owners.hyundaiusa.com/bin/common/remoteAction

Response Headers:

HTTP/1.1 200 OK
Server: Apache/2.4.51 (IUS) Communique/4.3.2 OpenSSL/1.0.2k-fips
X-Frame-Options: SAMEORIGIN
ADRUM_0: g:b2b918b8-2cd1-4d50-8e12-0fb818bc7bef
ADRUM_1: n:hyundai-prod_a5d7022d-6b0a-4522-9864-8274a3217b4a
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Cache-Control: no-cache
X-XSS-Protection: 1; mode=block
Content-Length: 64
Content-Type: text/html;charset=utf-8
Date: Tue, 19 Apr 2022 23:58:16 GMT
Connection: keep-alive
Strict-Transport-Security: max-age=86400; includeSubDomains

Request Headers

POST /bin/common/remoteAction HTTP/1.1
Host: owners.hyundaiusa.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
CSRF-Token: undefined
Content-Length: 605
Origin: https://owners.hyundaiusa.com
DNT: 1
Connection: keep-alive
Referer: https://owners.hyundaiusa.com/content/myhyundai/us/en/page/blue-link.html
Cookie: OptanonConsent=isIABGlobal=false&datestamp=Mon+Apr+04+2022+12%3A01%3A05+GMT-0400+(Eastern+Daylight+Time)&version=6.30.0&hosts=&consentId=6693cdf6-ebaa-4c65-928d-8aa26a178be8&interactionCount=1&landingPath=NotLandingPage&groups=C0001%3A1%2CC0003%3A1%2CC0002%3A1%2CBG8%3A1%2CC0004%3A1&geolocation=US%3BPA&AwaitingReconsent=false; OptanonAlertBoxClosed=2022-03-31T18:21:22.544Z; LPVID=EwZGVhYTVhOWE0ZTM3ZmI2; AMCV_3C3BCE0154FA24300A4C98A1%40AdobeOrg=-408604571%7CMCIDTS%7C19102%7CMCMID%7C31883741324953227464999190005400849772%7CMCOPTOUT-1650419894s%7CNONE%7CvVersion%7C4.6.0; dtm_token_sc=AQEHetjKq1lYOQENX1vnAQEBAQA; dtm_token=AQEHetjKq1lYOQENX1vnAQEBAQA; LPSID-41916303=YHECWswRR9uuaLiNq3M47A; at_check=true; AMCVS_3C3BCE0154FA24300A4C98A1%40AdobeOrg=1; csrf_token=undefined; jwt_token=JWT-eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJNeUh5dW5kYWkiLCJuYW1lIjoiZ2VvZmZAd2V5bC5tZSIsImlzcyI6Imh0dHBzOi8vb3duZXJzLmh5dW5kYWl1c2EuY29tIiwiZXhwIjoxNjUwNDMwMjMyODcyLCJpYXQiOjE2NTA0MTIyMzI4NzJ9.M6ytfuALWDwS1N1hXgMZGpvintRTNbchDtwvUzSTQ3I; s_name=XXXXX; isValidatedVehicle=false; s_sq=hmahyundaiowners%3D%2526c.%2526a.%2526activitymap.%2526page%253Dblue-link%2526link%253DSubmit%2526region%253DremotePresetValidatePinModal%2526pageIDType%253D1%2526.activitymap%2526.a%2526.c%2526pid%253Dblue-link%2526pidt%253D1%2526oid%253Dfunctiononclick%252528event%252529%25257BSave_Submit_Remote_Preset%252528this%252529%25253Bthis.disabled%25253Dtrue%25253B%25257D%2526oidt%253D2%2526ot%253DSUBMIT; s_cc=true; s_ppv=blue-link%2C30%2C18%2C1238; s_tp=4193; mbox=session#4b65d40c701a4900bc8c2ef27b948b8c#1650414052
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin

And under the "request" tab in Network this is the payload:

vin=XXXXX&username=XXXX&token=JWT-eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJNeUh5dW5kYWkiLCJuYW1lIjoiZ2VvZmZAd2V5bC5tZSIsImlzcyI6Imh0dHBzOi8vb3duZXJzLmh5dW5kYWl1c2EuY29tIiwiZXhwIjoxNjUwNDMwMjMyODcyLCJpYXQiOjE2NTA0MTIyMzI4NzJ9.M6ytfuALWDwS1N1hXgMZGpvintRTNbchDtwvUzSTQ3I&pin=4203&url=https%3A%2F%2Fowners.hyundaiusa.com%2Fcontent%2Fmyhyundai%2Fus%2Fen%2Fpage%2Fblue-link.html&airCtrl=true&igniOnDuration=NaN&airTempvalue=LO&defrost=false&heating1=0&gen=2&regId=H00004152526VKM8KRDAF9NU069614&seatHeaterVentInfo=%7B%22drvSeatHeatState%22%3A%222%22%7D&service=postRemoteFatcStart

Are you sure this is setting charging limits? It looks to be remote start. Just to confirm remote start is working for you?

cdnninja avatar May 19 '22 02:05 cdnninja

Honestly it's been so long I can't recall for sure. But yes I believe it was for setting the charger limit.

And yes, remote start from the app works 100% fine.

FuzzyMistborn avatar May 19 '22 03:05 FuzzyMistborn

I'm also wondering if I can help sniff Hyundai traffic to get charge limits (and other things too, if helpful) working?

I set the AC Charge Limit to 80%, and this is the traffic I see in Chrome (I removed some identifying information, but let me know if you need any of it):

Headers:

General:
Request URL: https://owners.hyundaiusa.com/bin/common/electricVehicle
Request Method: POST
Status Code: 200 OK
Remote Address: 104.114.3.79:443
Referrer Policy: strict-origin-when-cross-origin
Response:
ADRUM_0: g:13d34947-fd25-4cd2-a48e-70ebfc3cd090
ADRUM_1: n:hyundai-prod_a5d7022d-6b0a-4522-9864-8274a3217b4a
ADRUM_2: d:7642
Cache-Control: no-cache
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 1007
Content-Type: application/json
Date: Fri, 01 Jul 2022 16:57:36 GMT
Server: Apache/2.4.51 (IUS) Communique/4.3.2 OpenSSL/1.0.2k-fips
Strict-Transport-Security: max-age=86400; includeSubDomains
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Request:
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Content-Length: 631
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Cookie: <<removed>>
CSRF-Token: undefined
Host: owners.hyundaiusa.com
Origin: https://owners.hyundaiusa.com
Referer: https://owners.hyundaiusa.com/content/myhyundai/us/en/page/dashboard.html
sec-ch-ua: ".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "macOS"
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
X-Requested-With: XMLHttpRequest

And under Payload, I see this:

targetSOCData: {"targetSOClist":[{"plugType":0,"targetSOClevel":80},{"plugType":1,"targetSOClevel":80}]}
token: <<removed>>
vin: <<removed>>
url: https://owners.hyundaiusa.com/content/myhyundai/us/en/page/dashboard.html
regId: H00004052287VKM8KRDAF4NU064255
gen: 2
username: <<removed>>
service: setTargetSOC

It seems like "plugType 0" is DC charging, and "plugType 1" is AC charging.

Hope that's helpful. Let me know if there's anything else I can do!

paultoben avatar Jul 01 '22 17:07 paultoben

Looks like this API is a bit different than the mobile app. I think we will need the mobile app version sniffed to make this work.

cdnninja avatar Oct 30 '22 20:10 cdnninja

Gotcha. Looking at the wiki instructions i'm not in a position to do that right now but maybe I can in a few weeks. Hopefully someone else can.

FuzzyMistborn avatar Oct 30 '22 20:10 FuzzyMistborn

Not an easy item. I searched online and noticed bluelinky too hasn't reverse engineered this for hyundai USA.

cdnninja avatar Oct 30 '22 20:10 cdnninja

Hello, I have similar issue since one actualization in the past. Sorry, I do not remember when it stop to work but I think that it was when "Target vehicle" field was available. I write it just in case it hepls. Now, It works only if I set the new limits trought the control arrows (one step only to avoid the dobuble command issue) imagen

But it does do nothing if the order is set by an automatization. I am using NodeRed: imagen (Same if I tried a regular automatization) imagen

Same ressult if Target vehicle is filled or let in blank. I have an e-niro, EU. Thank you for your work!!

Gardanjerte avatar Apr 14 '23 10:04 Gardanjerte

@Gardanjerte you are EU not USA. Please open a new issue to not clutter this Hyundai USA thread. As an initial feedback try set both AC and DC limits as the API requires it and report back in a new thread. I thought logic caught that if missing it would use the existing value but I could be wrong.

cdnninja avatar Apr 14 '23 15:04 cdnninja

Sorry to mix issues. I create a new issue only for traceability, as your recomendation makes it works properly. I already closed it. The new issue is #629 Thank you

Gardanjerte avatar Apr 16 '23 16:04 Gardanjerte

Could you create a pr to solve against https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/blob/master/hyundai_kia_connect_api/KiaUvoAPIUSA.py?

cdnninja avatar Mar 29 '24 20:03 cdnninja

Yup. You can create your own fork from the link above. Find the lines related to the charge endpoint that doesn't work and edit. Then create a pull request from your edits. After that I can review and help you with syntax etc.

If you sniffed traffic like above that's the hardest part.

cdnninja avatar Mar 29 '24 21:03 cdnninja

Hey folks, I need this, took a stab here - https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api/pull/539

stephenjamieson avatar Mar 29 '24 22:03 stephenjamieson

My link was the wrong api but you sorted that out. Thanks for doing that! I have merged. When by a pc I'll bump the repo manifest file or feel free to drop a pr for that.

cdnninja avatar Mar 30 '24 00:03 cdnninja

Just tested and it worked for me. Hoping it's working for everyone else!

stephenjamieson avatar Mar 31 '24 15:03 stephenjamieson

@cdnninja both setting charge and start charge is working for me, I think this can be closed and the readme can be updated.

stephenjamieson avatar Apr 02 '24 21:04 stephenjamieson