Hyundai-Kia-Connect / kia_uvo

A Home Assistant HACS integration that supports Kia Connect(Uvo) and Hyundai Bluelink. The integration supports the EU, Canada and the USA.
MIT License
410 stars 84 forks source link

EU Genesis Support #682

Open pdunkley opened 1 year ago

pdunkley commented 1 year ago

Is your feature request related to a problem? Please describe. My wife and I have two Hyundai group cars. A Hyundai Tuscon Plug-in Hybrid (Bluelink) and a Genesis GV60 EV (GCS). I can currently use this integration with the Hyndai but not the Genesis.

Describe the solution you'd like Genesis Connected Services is effectively the same as Hyndai Bluelink and Kia Connect. It would be great if support for Genesis cars could be added to this integration.

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

Describe alternatives you've considered

Additional context

cdnninja commented 1 year ago

Most likely but someone needs to sniff the traffic. What country are you looking for?

pdunkley commented 1 year ago

I am in the UK, so that would be the EU region for this app.

lmuser22 commented 1 year ago

+1 for Upgrade with Support of Genesis :)

cdnninja commented 1 year ago

We need someone who is a genesis owner sniff the traffic.

lmuser22 commented 1 year ago

What i have to do? I have a GV60

cdnninja commented 1 year ago

Does it have a website you can control the car on or only an app?

lmuser22 commented 1 year ago

Only App Control > Does it have a website you can control the car on or only an app?

cdnninja commented 1 year ago

If only an app it takes some work. Someone would need to either share a login, add someone as a second user or sniff the traffic themselves.

lmuser22 commented 1 year ago

if someone tells me how, i could sniff the traffic

AshishMBakshi commented 1 year ago

Does it have a website you can control the car on or only an app?

There is a site - owners.genesis.com

lmuser22 commented 1 year ago

Only US :/ not DE / UK

cdnninja commented 1 year ago

https://archive.ph/k1hIG are steps to sniff traffic.

cdnninja commented 1 year ago

Does it have a website you can control the car on or only an app?

There is a site - owners.genesis.com

Are you interested in US support?

AshishMBakshi commented 1 year ago

Does it have a website you can control the car on or only an app?

There is a site - owners.genesis.com

Are you interested in US support?

Yes, US support would be great. What info do you need from the browser? I noticed that at some point in the loading process, it navigated to a UVO URL, so hopefully it's not too different from the Kia system.

lmuser22 commented 1 year ago

https://archive.ph/k1hIG are steps to sniff traffic.

too complex for me but would share my account. Just need to figure out how to set up a second user with less rights (Unlock / Start....)

cdnninja commented 1 year ago

Let's hold off sharing. I got the key items from the login page. Waiting for someone on the bluelinky side to help on one item before we test.

cdnninja commented 1 year ago

Thinking an account would help. If anyone able to share let me know.

cdnninja commented 1 year ago

Anyone familiar enough with python to test this out for me? https://github.com/Hyundai-Kia-Connect/hyundai_kia_connect_api

Example test code:

from pathlib import Path
import logging
import sys
import os

path_root = r"C:\path to files\hyundai_kia_connect_api"
sys.path.append(str(path_root))
from hyundai_kia_connect_api import *
from hyundai_kia_connect_api.exceptions import *

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG, format='%(asctime)s %(name)s %(levelname)s:%(message)s')
logger = logging.getLogger(__name__)

vm = VehicleManager(region=1, brand=3, username="username", password="pass", pin="", geocode_api_enable = True)
print(vm.check_and_refresh_token())

vm.update_all_vehicles_with_cached_state()
print(vm.vehicles)
martinpelant commented 11 months ago

@cdnninja here's my output: (I have GV60 in the UK)

2023-09-12 21:14:18,831 hyundai_kia_connect_api.KiaUvoApiEU DEBUG:hyundai_kia_connect_api - Get Device ID request: https://prd-eu-ccapi.genesis.com:443/api/v1/spa/notifications/register {'ccsp-service-id': '3020afa2-30ff-412a-aa51-d28fbe901e10', 'ccsp-application-id': 'f11f2b86-e0e7-4851-90df-5600b01d8b70', 'Stamp': 'ImpZIJ2NNURLI0cNUotk8b8G05h70TJzbvXLirZ/QKkhptv+KoiLoNhaihlSy5I=', 'Content-Type': 'application/json;charset=UTF-8', 'Host': 'prd-eu-ccapi.genesis.com:443', 'Connection': 'Keep-Alive', 'Accept-Encoding': 'gzip', 'User-Agent': 'okhttp/3.12.0'} {'pushRegId': '2da9de0f4580579491260932903cb51f5da3eeb44fdf91226536eba227169773', 'pushType': 'GCM', 'uuid': '594c0500-3bb3-4ebf-bb09-d684d8434a29'}
2023-09-12 21:14:18,837 urllib3.connectionpool DEBUG:Starting new HTTPS connection (1): prd-eu-ccapi.genesis.com:443
2023-09-12 21:14:18,998 urllib3.connectionpool DEBUG:https://prd-eu-ccapi.genesis.com:443 "POST /api/v1/spa/notifications/register HTTP/1.1" 200 140
2023-09-12 21:14:19,000 hyundai_kia_connect_api.KiaUvoApiEU DEBUG:hyundai_kia_connect_api - Get Device ID response: {'retCode': 'S', 'resCode': '0000', 'resMsg': {'deviceId': 'f29e4c01-3420-48d6-8dfb-52e56a64c641'}, 'msgId': '10d36596-a5a5-483b-810b-52606017866f'}
2023-09-12 21:14:19,000 hyundai_kia_connect_api.KiaUvoApiEU DEBUG:hyundai_kia_connect_api - Get cookies request: https://prd-eu-ccapi.genesis.com:443/api/v1/user/oauth2/authorize?response_type=code&state=test&client_id=3020afa2-30ff-412a-aa51-d28fbe901e10&redirect_uri=https://prd-eu-ccapi.genesis.com:443/api/v1/user/oauth2/redirect&lang=en
2023-09-12 21:14:19,001 urllib3.connectionpool DEBUG:Starting new HTTPS connection (1): prd-eu-ccapi.genesis.com:443
2023-09-12 21:14:19,118 urllib3.connectionpool DEBUG:https://prd-eu-ccapi.genesis.com:443 "GET /api/v1/user/oauth2/authorize?response_type=code&state=test&client_id=3020afa2-30ff-412a-aa51-d28fbe901e10&redirect_uri=https://prd-eu-ccapi.genesis.com:443/api/v1/user/oauth2/redirect&lang=en HTTP/1.1" 400 96
2023-09-12 21:14:19,119 hyundai_kia_connect_api.KiaUvoApiEU DEBUG:hyundai_kia_connect_api - Get cookies response: {'account': 'MmNlY2I4OGEtZmNjOS00YmNlLWE3M2ItZjg5MzA1YjJmYTlm.8b1102fdfa4a96b792e24639f1c7aad7e8c5406d', 'TS01f622c7': '01cbaa6f70a2a1b7de0658aef0f85b8e68f46857d61f2a04665d2856d66776996dd9e97e10eb35f51ea7e41042dd427ee3616ffc6d'}
2023-09-12 21:14:19,122 urllib3.connectionpool DEBUG:Starting new HTTPS connection (1): prd-eu-ccapi.genesis.com:443
2023-09-12 21:14:19,242 urllib3.connectionpool DEBUG:https://prd-eu-ccapi.genesis.com:443 "POST /api/v1/user/language HTTP/1.1" 401 100
2023-09-12 21:14:19,246 urllib3.connectionpool DEBUG:Starting new HTTPS connection (1): prd-eu-ccapi.genesis.com:443
2023-09-12 21:14:19,378 urllib3.connectionpool DEBUG:https://prd-eu-ccapi.genesis.com:443 "POST /api/v1/user/signin HTTP/1.1" 401 100
2023-09-12 21:14:19,380 hyundai_kia_connect_api.KiaUvoApiEU DEBUG:hyundai_kia_connect_api - Sign In Response: {'errId': 'a29d650f-96a1-42d0-a8fb-00a397f2b5e5', 'errCode': '4010', 'errMsg': 'Require authentication'}
2023-09-12 21:14:19,380 hyundai_kia_connect_api.KiaUvoApiEU DEBUG:hyundai_kia_connect_api - get_authorization_code_with_redirect_url failed
2023-09-12 21:14:19,382 urllib3.connectionpool DEBUG:Starting new HTTPS connection (1): prd-eu-ccapi.genesis.com:443
2023-09-12 21:14:19,505 urllib3.connectionpool DEBUG:https://prd-eu-ccapi.genesis.com:443 "GET /api/v1/user/integrationinfo HTTP/1.1" 200 46
2023-09-12 21:14:19,507 hyundai_kia_connect_api.KiaUvoApiEU DEBUG:hyundai_kia_connect_api - IntegrationInfo Response: {'userId': '', 'serviceId': '', 'serviceName': ''}
2023-09-12 21:14:19,508 urllib3.connectionpool DEBUG:Starting new HTTPS connection (1): accounts-eu.genesis.com:443
2023-09-12 21:14:19,946 urllib3.connectionpool DEBUG:https://accounts-eu.genesis.com:443 "GET /auth/realms/eugenesisidm/protocol/openid-connect/auth?client_id=3020afa2-30ff-412a-aa51-d28fbe901e10&scope=openid%20profile%20email%20phone&response_type=code&hkid_session_reset=true&redirect_uri=https://prd-eu-ccapi.genesis.com:443/api/v1/user/integration/redirect/login&ui_locales=en&state=: HTTP/1.1" 404 1265
2023-09-12 21:14:19,949 hyundai_kia_connect_api.KiaUvoApiEU DEBUG:hyundai_kia_connect_api - LoginForm https://accounts-eu.genesis.com/auth/realms/eugenesisidm/protocol/openid-connect/auth?client_id=3020afa2-30ff-412a-aa51-d28fbe901e10&scope=openid%20profile%20email%20phone&response_type=code&hkid_session_reset=true&redirect_uri=https://prd-eu-ccapi.genesis.com:443/api/v1/user/integration/redirect/login&ui_locales=en&state=: - Response:

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width" />
<title>GENESIS ACCOUNT</title>
<link rel="stylesheet" href="/css/style.css;jsessionid=02DB4D54715F08E4A3CC07C4E6F82465.apache21" />
<link rel="shortcut icon" href="/images/favicon.ico;jsessionid=02DB4D54715F08E4A3CC07C4E6F82465.apache21" />
</head>
<body>
    <div class="wrap">
        <!-- header -->
        <header class="only_img">
            <h1><a href="#"><img src="/images/logo.png;jsessionid=02DB4D54715F08E4A3CC07C4E6F82465.apache21" alt="GENESIS"></a></h1>
        </header>
        <!-- //header -->
        <div>
            <!-- container -->
            <div class="full_page">
                <div class="full_page_con">
                    <h1>We are sorry.</h1>
                    <h2>Page not found.</h2>
                </div>
            </div>
            <!-- //container -->
        </div>
        <footer>
            © Copyright Genesis Motor Europe. ALL RIGHTS RESERVED.
        </footer>
    </div>
</body>
</html>

Traceback (most recent call last):
  File "/Users/pelant/Downloads/hyundai_kia_connect_api-master/hyundai_kia_connect_api/KiaUvoApiEU.py", line 234, in login
    authorization_code = self._get_authorization_code_with_redirect_url(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pelant/Downloads/hyundai_kia_connect_api-master/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1164, in _get_authorization_code_with_redirect_url
    parsed_url = urlparse(response["redirectUrl"])
                          ~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'redirectUrl'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/pelant/Downloads/hyundai_kia_connect_api-master/./test-genesis.py", line 15, in <module>
    print(vm.check_and_refresh_token())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pelant/Downloads/hyundai_kia_connect_api-master/hyundai_kia_connect_api/VehicleManager.py", line 123, in check_and_refresh_token
    self.initialize()
  File "/Users/pelant/Downloads/hyundai_kia_connect_api-master/hyundai_kia_connect_api/VehicleManager.py", line 67, in initialize
    self.token: Token = self.api.login(self.username, self.password)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pelant/Downloads/hyundai_kia_connect_api-master/hyundai_kia_connect_api/KiaUvoApiEU.py", line 239, in login
    authorization_code = self._get_authorization_code_with_form(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/pelant/Downloads/hyundai_kia_connect_api-master/hyundai_kia_connect_api/KiaUvoApiEU.py", line 1188, in _get_authorization_code_with_form
    login_form_action_url = soup.find("form")["action"].replace("&amp;", "&")
                            ~~~~~~~~~~~~~~~~~^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
martinpelant commented 10 months ago

@cdnninja any ideas what the right URL might be?

cdnninja commented 9 months ago

@martinpelant no I don't. Ideally need someone who knows python and has one of these cars willing to figure this out. I took it as far as I can. I also don't own a car that works on this integration anymore so can't say I spend much time on it.

bufu2012 commented 9 months ago

I tried using for a GV60 within Germany (DE) - without success.

What do I need to do?

juodikis commented 1 month ago

Any news on this? How can we (people with Genesis but 0 knowledge in python) can help?