Comments (5)
I have been using the above python in a script in eventghost ( modified a bit) and using MQTT to setup sensors, device_tracker and switches in HA. Its OK, reasonably reliable, but sometimes doesn't update due to throttling (I'm using 10 minute interval when not_home and 1 hour when home)
from kia_uvo.
Thanks to https://openwb.de/forum/viewtopic.php?f=5&t=1215&start=10
Here are endpoints and handling
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()
from kia_uvo.
@holdestmade that sounds great. Iam quiet new to programming.
Any chance you could provide that eventghost script ?
from kia_uvo.
Hi all,
I have baked a custom integration for EU Kia Uvo, this will be working for new account types. Thanks for your hard work @wcomartin
Warning ahead; this is pre-alpha phase, please do not expect something fully functional, I will improve the integration by time.
https://github.com/fuatakgun/kia_uvo
You can install this either manually copying files or using HACS. Configuration can be done on UI, you need to enter your username and password, (I know, translations are missing!).
- it will only fetch values for the first car, I am not sure if there are people outside using Kia Uvo with multiple cars :slight_smile:
- update - It will fetch the cached information every 30 minutes from Kia Servers.
- force update - It will ask your car for the latest data every 2 hours.
- It will not force update between 10PM to 6AM. I am trying to be cautious here.
I have posted an example screenshot from my own car.
from kia_uvo.
from kia_uvo.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kia_uvo.