Seite 2 von 8

Re: Soc Modul Kia E-Niro 2020

Verfasst: Fr Jun 26, 2020 1:42 pm
von Cobra
Zugangsdaten sind noch aktuell.

Re: Soc Modul Kia E-Niro 2020

Verfasst: Mo Jun 29, 2020 10:01 pm
von Cobra
Hi

Hab die Datei bluelinksoc.py mal abgeändert in:

Code: Alles auswählen

import sys
import requests
import uuid
import json
import urllib.parse as urlparse
from urllib.parse import parse_qs

email = str(sys.argv[1])
password = str(sys.argv[2])
pin = str(sys.argv[3])
#vin = str(sys.argv[4])

def main():
    #diviceID
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/notifications/register'
    headers = {
        'ccsp-service-id': 'fdc85c00-0a2f-4c64-bcb4-2cfb1500730a',
        'Content-type': 'application/json;charset=UTF-8',
        'Content-Length': '80',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = {"pushRegId":"1","pushType":"GCM","uuid": str(uuid.uuid1())}
    response = requests.post(url, json = data, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        deviceId = response['resMsg']['deviceId']
        #print(deviceId)
    else:
        print('NOK diviceID')
        return

    #cookie für login
    session = requests.Session()
    response = session.get('https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/authorize?response_type=code&state=test&client_id=fdc85c00-0a2f-4c64-bcb4-2cfb1500730a&redirect_uri=https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/redirect')
    if response.status_code == 200:
        cookies = session.cookies.get_dict()
        #print(cookies)
    else:
        print('NOK cookie für login')
        return

    #login
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/signin'
    headers = {'Content-type': 'application/json'}
    data = {"email": email,"password": password}
    response = requests.post(url, json = data, headers = headers, cookies = cookies)
    if response.status_code == 200:
        response = json.loads(response.text)
        response = response['redirectUrl']
        parsed = urlparse.urlparse(response)
        authCode = ''.join(parse_qs(parsed.query)['code'])
        #print(authCode)
    else:
        print('NOK login')
        return

    #token
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/token'
    headers = {
        'Authorization': 'Basic ZmRjODVjMDAtMGEyZi00YzY0LWJjYjQtMmNmYjE1MDA3MzBhOnNlY3JldA==',
        'Content-type': 'application/x-www-form-urlencoded',
        'Content-Length': '154',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = 'grant_type=authorization_code&redirect_uri=https%3A%2F%2Fprd.eu-ccapi.kia.com%3A8080%2Fapi%2Fv1%2Fuser%2Foauth2%2Fredirect&code=' + authCode
    response = requests.post(url, data = data, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        access_token = response['token_type'] + ' ' + response['access_token']
        #print(access_token)
    else:
        print('NOK token')
        return

    #vehicles
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/vehicles'
    headers = {
        'Authorization': access_token,
        'ccsp-device-id': deviceId,
        'ccsp-application-id': '693a33fa-c117-43f2-ae3b-61a02d24f417',
        'offset': '1',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    response = requests.get(url, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        vehicleId = response['resMsg']['vehicles'][0]['vehicleId']
        #print(vehicleId)
    else:
        print('NOK vehicles')
        return

    #vehicles/profile

    #prewakeup
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/vehicles/' + vehicleId + '/control/engine'
    headers = {
        'Authorization': access_token,
        'ccsp-device-id': deviceId,
        'ccsp-application-id': '693a33fa-c117-43f2-ae3b-61a02d24f417',
        'offset': '1',
        'Content-Type': 'application/json;charset=UTF-8',
        'Content-Length': '72',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = {"action":"prewakeup","deviceId": deviceId}
    response = requests.post(url, json = data, headers = headers)
    if response.status_code == 200:
        #print(response.text)
        response = ''
    else:
        print('NOK prewakeup')
        return

    #pin
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/pin'
    headers = {
        'Authorization': access_token,
        'Content-type': 'application/json;charset=UTF-8',
        'Content-Length': '64',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = {"deviceId": deviceId,"pin": pin}
    response = requests.put(url, json = data, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        controlToken = 'Bearer ' + response['controlToken']
        #print(controlToken)
    else:
        print('NOK pin')
        return

    #status
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v2/spa/vehicles/' + vehicleId + '/status'
    headers = {
        'Authorization': controlToken,
        'ccsp-device-id': deviceId,
        'ccsp-application-id': '693a33fa-c117-43f2-ae3b-61a02d24f417',
        'offset': '1',
        'Host': 'prd.eu-ccapi.kia.com::8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    response = requests.get(url, headers = headers)
    if response.status_code == 200:
        #print(response.text)
        response = json.loads(response.text)
        soc = response['resMsg']['evStatus']['batteryStatus']
        #print(soc)
        f = open('/var/www/html/openWB/ramdisk/soc', 'w')
        f.write(str(soc))
        f.close()
    else:
        print('NOK status')
        return

if __name__ == '__main__':
    main()
in main.sh . /var/www/html/openWB/openwb.conf hinzugefügt.

Fehlermeldung ist:

Code: Alles auswählen

main.sh: 12: main.sh: cannot open tmpintervall: No such file
main.sh: 12: main.sh: soctimer: not found
root@raspberrypi:/var/www/html/openWB/modules/soc_bluelink# Traceback (most recent call last):
  File "/var/www/html/openWB/modules/soc_bluelink/bluelinksoc.py", line 168, in <module>
    main()
  File "/var/www/html/openWB/modules/soc_bluelink/bluelinksoc.py", line 157, in main
    response = json.loads(response.text)
  File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)


Wo liegt der Fehler?

Re: Soc Modul Kia E-Niro 2020

Verfasst: Mi Jul 01, 2020 9:08 am
von mattle1957
Hallo,

könnte es daran liegen, dass es bei Kia nicht "Bluelink", sondern "UVO" heisst?

Grüße
Martin

Re: Soc Modul Kia E-Niro 2020

Verfasst: Mi Jul 08, 2020 7:34 am
von Cobra
Das Modul ist das selbe es müssen nur andere ids und Adressen eingetragen werden.

Re: Soc Modul Kia E-Niro 2020

Verfasst: Mi Jul 08, 2020 7:54 am
von openWB
Weißt du / kannst du alles nötige abändern?

Re: Soc Modul Kia E-Niro 2020

Verfasst: Mi Jul 15, 2020 7:35 pm
von Cobra
Hi

Bin ein gutes stück weiter.Anmelden geht. Leider funktioniert das Auslesen nicht.

Code: Alles auswählen

def main():
#diviceID
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/notifications/register'
    headers = {
        'ccsp-service-id': 'fdc85c00-0a2f-4c64-bcb4-2cfb1500730a',
        'Content-type': 'application/json;charset=UTF-8',
        'Content-Length': '80',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = {"pushRegId":"1","pushType":"GCM","uuid": str(uuid.uuid1())}
    response = requests.post(url, json = data, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        deviceId = response['resMsg']['deviceId']
        print(deviceId)
    else:
        print('NOK diviceID')
        return

    #cookie für login
    session = requests.Session()
    response = session.get('https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/authorize?response_type=code&state=test&client_id=fdc85c00-0a2f-4c64-bcb4-2cfb1500730a&redirect_uri=https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/redirect')
    if response.status_code == 200:
        cookies = session.cookies.get_dict()
        #print(cookies)
    else:
        print('NOK cookie für login')
        return

    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/language' 
    headers = {'Content-type': 'application/json'}
    data = {"lang": "en"}
    response = requests.post(url, json = data, headers = headers, cookies = cookies)

    #login
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/signin' 
    headers = {'Content-type': 'application/json'}
    data = {"email": email,"password": password}
    response = requests.post(url, json = data, headers = headers, cookies = cookies)
    if response.status_code == 200:
        response = json.loads(response.text)
        response = response['redirectUrl']
        parsed = urlparse.urlparse(response)
        authCode = ''.join(parse_qs(parsed.query)['code'])
        #print(authCode)
	
    else:
        print('NOK login')
        return

    #token
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/token'
    headers = {
        'Authorization': 'Basic ZmRjODVjMDAtMGEyZi00YzY0LWJjYjQtMmNmYjE1MDA3MzBhOnNlY3JldA==',
        'Content-type': 'application/x-www-form-urlencoded',
        'Content-Length': '150',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = 'grant_type=authorization_code&redirect_uri=https%3A%2F%2Fprd.eu-ccapi.kia.com%3A8080%2Fapi%2Fv1%2Fuser%2Foauth2%2Fredirect&code=' + authCode
    response = requests.post(url, data = data, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        access_token = response['token_type'] + ' ' + response['access_token']
        #print(access_token)
    else:
        print('NOK token')
        return

    #vehicles
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/vehicles'
    headers = {
        'Authorization': access_token,
        'ccsp-device-id': deviceId,
        'ccsp-application-id': '693a33fa-c117-43f2-ae3b-61a02d24f417',
        'offset': '1',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    response = requests.get(url, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        vehicleId = response['resMsg']['vehicles'][0]['vehicleId']
        #print(vehicleId)
    else:
        print('NOK vehicles')
        return

    #vehicles/profile

    #prewakeup
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/vehicles/' + vehicleId + '/control/engine'
    headers = {
        'Authorization': access_token,
        'ccsp-device-id': deviceId,
        'ccsp-application-id': '693a33fa-c117-43f2-ae3b-61a02d24f417',
        'offset': '1',
        'Content-Type': 'application/json;charset=UTF-8',
        'Content-Length': '72',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = {"action":"prewakeup","deviceId": deviceId}
    response = requests.post(url, json = data, headers = headers)
    if response.status_code == 200:
        #print(response.text)
        response = ''
    else:
        print('NOK prewakeup')
        return

    #pin
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/pin'
    headers = {
        'Authorization': access_token,
        'Content-type': 'application/json;charset=UTF-8',
        'Content-Length': '64',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = {"deviceId": deviceId,"pin": pin}
    response = requests.put(url, json = data, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        controlToken = 'Bearer ' + response['controlToken']
        #print(controlToken)
    else:
        print('NOK pin')
        return

    #status
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/vehicles/' + vehicleId + '/status'
    headers = {
        'Authorization': controlToken,
        'ccsp-device-id': deviceId,
        'ccsp-application-id': '693a33fa-c117-43f2-ae3b-61a02d24f417',
        'offset': '1',
        'Host': 'prd.eu-ccapi.kia.com::8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    response = requests.get(url, headers = headers)
    if response.status_code == 200:
        print(response.text)
        response = json.loads(response.text)
        soc = response['resMsg']['evStatus']['batteryStatus']
        print(soc)
        f = open('/var/www/html/openWB/ramdisk/soc', 'w')
        f.write(str(soc))
        f.close()
    else:
        print('NOK status')
        return

if __name__ == '__main__':
    main()

Fehlermeldung:

Code: Alles auswählen

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>Blocking Page</title>
 </head>
 <body>
  <div align="center">

        <br />
        <br />

        <form action="login.php" method="post">
        <fieldset>

                        <br> <span style="color:#FF0000"> <접근 제한>
                        <br>
                        <br> <span style="color:#000000"> 보안 운영팀에 문의 바랍니다
                        <br>
                        <br> 당신의 차단 ID 는 15663020050990421609 입니다.
                        <a href='javascript:history.back();'>
                        <br>
                        <p class="submit"><input type="submit" value="Go Back" name="Go Back"></p>

        </fieldset>

        </form>
        <br />
        <br />


<div>
 </body>
</html>
Traceback (most recent call last):
  File "/var/www/html/openWB/modules/soc_bluelink/bluelinksoc.py", line 174, in <module>
    main()
  File "/var/www/html/openWB/modules/soc_bluelink/bluelinksoc.py", line 163, in main
    response = json.loads(response.text)
  File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Hat noch einer eine Idee?

Re: Soc Modul Kia E-Niro 2020

Verfasst: Do Jul 16, 2020 4:53 am
von openWB
Erwartet wird eine JSON Antwort die aber nicht kommt und der Decoder daher einen Error wirft.

Re: Soc Modul Kia E-Niro 2020

Verfasst: Do Jul 16, 2020 10:48 am
von Cobra
Fertig es funktioniert.
Mein Dank geht an Plips-nl

Angabe der Vin ist erforderlich.
Ausgabe SoC und Ladestatus.

soc: 96
charging: False


Code: Alles auswählen

import sys
import requests
import uuid
import json
import urllib.parse as urlparse
from urllib.parse import parse_qs

email = str(sys.argv[1])
password = str(sys.argv[2])
pin = str(sys.argv[3])
vin = str(sys.argv[4])

def main():
#diviceID
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/notifications/register'
    headers = {
        'ccsp-service-id': 'fdc85c00-0a2f-4c64-bcb4-2cfb1500730a',
        'Content-type': 'application/json;charset=UTF-8',
        'Content-Length': '80',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = {"pushRegId":"1","pushType":"GCM","uuid": str(uuid.uuid1())}
    response = requests.post(url, json = data, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        deviceId = response['resMsg']['deviceId']
        print(deviceId)
    else:
        print('NOK diviceID')
        return

    #cookie für login
    session = requests.Session()
    response = session.get('https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/authorize?response_type=code&state=test&client_id=fdc85c00-0a2f-4c64-bcb4-2cfb1500730a&redirect_uri=https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/redirect')
    if response.status_code == 200:
        cookies = session.cookies.get_dict()
        #print(cookies)
    else:
        print('NOK cookie für login')
        return

    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/language' 
    headers = {'Content-type': 'application/json'}
    data = {"lang": "en"}
    response = requests.post(url, json = data, headers = headers, cookies = cookies)

    #login
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/signin' 
    headers = {'Content-type': 'application/json'}
    data = {"email": email,"password": password}
    response = requests.post(url, json = data, headers = headers, cookies = cookies)
    if response.status_code == 200:
        response = json.loads(response.text)
        response = response['redirectUrl']
        parsed = urlparse.urlparse(response)
        authCode = ''.join(parse_qs(parsed.query)['code'])
        #print(authCode)
	
    else:
        print('NOK login')
        return

    #token
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/token'
    headers = {
        'Authorization': 'Basic ZmRjODVjMDAtMGEyZi00YzY0LWJjYjQtMmNmYjE1MDA3MzBhOnNlY3JldA==',
        'Content-type': 'application/x-www-form-urlencoded',
        'Content-Length': '150',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = 'grant_type=authorization_code&redirect_uri=https%3A%2F%2Fprd.eu-ccapi.kia.com%3A8080%2Fapi%2Fv1%2Fuser%2Foauth2%2Fredirect&code=' + authCode
    response = requests.post(url, data = data, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        access_token = response['token_type'] + ' ' + response['access_token']
        #print(access_token)
    else:
        print('NOK token')
        return

    #vehicles
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/vehicles'
    headers = {
        'Authorization': access_token,
        'ccsp-device-id': deviceId,
        'ccsp-application-id': '693a33fa-c117-43f2-ae3b-61a02d24f417',
        'offset': '1',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    response = requests.get(url, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        vehicleId = response['resMsg']['vehicles'][0]['vehicleId']
        #print(vehicleId)
    else:
        print('NOK vehicles')
        return

    #vehicles/profile

    #prewakeup
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/vehicles/' + vehicleId + '/control/engine'
    headers = {
        'Authorization': access_token,
        'ccsp-device-id': deviceId,
        'ccsp-application-id': '693a33fa-c117-43f2-ae3b-61a02d24f417',
        'offset': '1',
        'Content-Type': 'application/json;charset=UTF-8',
        'Content-Length': '72',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = {"action":"prewakeup","deviceId": deviceId}
    response = requests.post(url, json = data, headers = headers)
    if response.status_code == 200:
        #print(response.text)
        response = ''
    else:
        print('NOK prewakeup')
        return

    #pin
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/pin'
    headers = {
        'Authorization': access_token,
        'Content-type': 'application/json;charset=UTF-8',
        'Content-Length': '64',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = {"deviceId": deviceId,"pin": pin}
    response = requests.put(url, json = data, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        controlToken = 'Bearer ' + response['controlToken']
        #print(controlToken)
    else:
        print('NOK pin')
        return

    #status
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v2/spa/vehicles/' + vehicleId + '/status'
    headers = {
        'Authorization': controlToken,
        'ccsp-device-id': deviceId,
        'Content-Type': 'application/json'}
    response = requests.get(url, headers = headers)
    if response.status_code == 200:
       statusresponse = json.loads(response.text)
       #log (statusresponse)
       soc = statusresponse['resMsg']['evStatus']['batteryStatus']
       print('soc: ',soc)
       charging = statusresponse['resMsg']['evStatus']['batteryCharge']
       print('charging: ', charging)

       f = open('/var/www/html/openWB/ramdisk/soc', 'w')
       f.write(str(soc))
       f.close()   
    else:
         print('NOK status')
         return

if __name__ == '__main__':
    main()


Re: Soc Modul Kia E-Niro 2020

Verfasst: Do Jul 16, 2020 11:28 am
von mattle1957
Bitte um Info, wenn das Modul implementiert ist und wie die Einstellung aussehen sollte.
Fahre einen e Soul und würde dies auch gerne nutzen.
Danke!

Gruß
Martin

Re: Soc Modul Kia E-Niro 2020

Verfasst: Do Jul 16, 2020 11:34 am
von openWB
Cobra hat geschrieben: Do Jul 16, 2020 10:48 am Fertig es funktioniert.
Mein Dank geht an Plips-nl

Angabe der Vin ist erforderlich.
Ausgabe SoC und Ladestatus.

soc: 96
charging: False


Code: Alles auswählen

import sys
import requests
import uuid
import json
import urllib.parse as urlparse
from urllib.parse import parse_qs

email = str(sys.argv[1])
password = str(sys.argv[2])
pin = str(sys.argv[3])
vin = str(sys.argv[4])

def main():
#diviceID
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/notifications/register'
    headers = {
        'ccsp-service-id': 'fdc85c00-0a2f-4c64-bcb4-2cfb1500730a',
        'Content-type': 'application/json;charset=UTF-8',
        'Content-Length': '80',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = {"pushRegId":"1","pushType":"GCM","uuid": str(uuid.uuid1())}
    response = requests.post(url, json = data, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        deviceId = response['resMsg']['deviceId']
        print(deviceId)
    else:
        print('NOK diviceID')
        return

    #cookie für login
    session = requests.Session()
    response = session.get('https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/authorize?response_type=code&state=test&client_id=fdc85c00-0a2f-4c64-bcb4-2cfb1500730a&redirect_uri=https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/redirect')
    if response.status_code == 200:
        cookies = session.cookies.get_dict()
        #print(cookies)
    else:
        print('NOK cookie für login')
        return

    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/language' 
    headers = {'Content-type': 'application/json'}
    data = {"lang": "en"}
    response = requests.post(url, json = data, headers = headers, cookies = cookies)

    #login
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/signin' 
    headers = {'Content-type': 'application/json'}
    data = {"email": email,"password": password}
    response = requests.post(url, json = data, headers = headers, cookies = cookies)
    if response.status_code == 200:
        response = json.loads(response.text)
        response = response['redirectUrl']
        parsed = urlparse.urlparse(response)
        authCode = ''.join(parse_qs(parsed.query)['code'])
        #print(authCode)
	
    else:
        print('NOK login')
        return

    #token
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/token'
    headers = {
        'Authorization': 'Basic ZmRjODVjMDAtMGEyZi00YzY0LWJjYjQtMmNmYjE1MDA3MzBhOnNlY3JldA==',
        'Content-type': 'application/x-www-form-urlencoded',
        'Content-Length': '150',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = 'grant_type=authorization_code&redirect_uri=https%3A%2F%2Fprd.eu-ccapi.kia.com%3A8080%2Fapi%2Fv1%2Fuser%2Foauth2%2Fredirect&code=' + authCode
    response = requests.post(url, data = data, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        access_token = response['token_type'] + ' ' + response['access_token']
        #print(access_token)
    else:
        print('NOK token')
        return

    #vehicles
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/vehicles'
    headers = {
        'Authorization': access_token,
        'ccsp-device-id': deviceId,
        'ccsp-application-id': '693a33fa-c117-43f2-ae3b-61a02d24f417',
        'offset': '1',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    response = requests.get(url, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        vehicleId = response['resMsg']['vehicles'][0]['vehicleId']
        #print(vehicleId)
    else:
        print('NOK vehicles')
        return

    #vehicles/profile

    #prewakeup
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/spa/vehicles/' + vehicleId + '/control/engine'
    headers = {
        'Authorization': access_token,
        'ccsp-device-id': deviceId,
        'ccsp-application-id': '693a33fa-c117-43f2-ae3b-61a02d24f417',
        'offset': '1',
        'Content-Type': 'application/json;charset=UTF-8',
        'Content-Length': '72',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = {"action":"prewakeup","deviceId": deviceId}
    response = requests.post(url, json = data, headers = headers)
    if response.status_code == 200:
        #print(response.text)
        response = ''
    else:
        print('NOK prewakeup')
        return

    #pin
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/pin'
    headers = {
        'Authorization': access_token,
        'Content-type': 'application/json;charset=UTF-8',
        'Content-Length': '64',
        'Host': 'prd.eu-ccapi.kia.com:8080',
        'Connection': 'close',
        'Accept-Encoding': 'gzip, deflate',
        'User-Agent': 'okhttp/3.10.0'}
    data = {"deviceId": deviceId,"pin": pin}
    response = requests.put(url, json = data, headers = headers)
    if response.status_code == 200:
        response = json.loads(response.text)
        controlToken = 'Bearer ' + response['controlToken']
        #print(controlToken)
    else:
        print('NOK pin')
        return

    #status
    url = 'https://prd.eu-ccapi.kia.com:8080/api/v2/spa/vehicles/' + vehicleId + '/status'
    headers = {
        'Authorization': controlToken,
        'ccsp-device-id': deviceId,
        'Content-Type': 'application/json'}
    response = requests.get(url, headers = headers)
    if response.status_code == 200:
       statusresponse = json.loads(response.text)
       #log (statusresponse)
       soc = statusresponse['resMsg']['evStatus']['batteryStatus']
       print('soc: ',soc)
       charging = statusresponse['resMsg']['evStatus']['batteryCharge']
       print('charging: ', charging)

       f = open('/var/www/html/openWB/ramdisk/soc', 'w')
       f.write(str(soc))
       f.close()   
    else:
         print('NOK status')
         return

if __name__ == '__main__':
    main()

Habe es mal in die Nightly übernommen - bitte testen.