Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wake up Zoe #2671

Merged
merged 2 commits into from
Mar 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
92 changes: 32 additions & 60 deletions modules/soc_myrenault/zoenwake.py
@@ -1,73 +1,45 @@
#!/usr/bin/python
import sys
import os
import time
import getopt
import json
import urllib
import urllib2
import requests

loginID=str(sys.argv[1])
password=str(sys.argv[2])
location=str(sys.argv[3])
country=str(sys.argv[4])
vin=str(sys.argv[5])
chargepoint=str(sys.argv[6])
loginID = str(sys.argv[1])
password = str(sys.argv[2])
location = str(sys.argv[3])
country = str(sys.argv[4])
vin = str(sys.argv[5])
chargepoint = str(sys.argv[6])

named_tuple = time.localtime() # get struct_time
named_tuple = time.localtime()
time_string = time.strftime("%m/%d/%Y, %H:%M:%S myrenault wake lp"+chargepoint, named_tuple)
f = open('/var/www/html/openWB/ramdisk/zoereply1lp'+chargepoint, 'r')
android_config = json.loads(f.read())
f.close()
gigyarooturl = android_config['servers']['gigyaProd']['target']
gigyaapikey = android_config['servers']['gigyaProd']['apikey']
kamereonrooturl = android_config['servers']['wiredProd']['target']
#kamereonapikey = android_config['servers']['wiredProd']['apikey']
#kamereonapikey = 'Ae9FDWugRxZQAGm3Sxgk7uJn6Q4CGEA2'
gigyarooturl = 'https://accounts.eu1.gigya.com'
gigyaapi = '3_7PLksOyBRkHv126x5WhHb-5pqC1qFR8pQjxSeLB6nhAnPERTUlwnYoznHSxwX668'
kamereonrooturl = 'https://api-wired-prod-1-euw1.wrd-aws.com'
kamereonapikey = 'VAX7XYKGfa92yMvXculCkEFyfZbuM7Ss'
#print(time_string, 'gigyarooturl',gigyarooturl,gigyaapikey,kamereonrooturl,kamereonapikey)
#
f = open('/var/www/html/openWB/ramdisk/zoereply4lp'+chargepoint, 'r')
gigya_jwt = json.loads(f.read())
f.close()
gigya_jwttoken= gigya_jwt['id_token']
#print(time_string,'gigya_jwttoken',gigya_jwttoken)
#
f = open('/var/www/html/openWB/ramdisk/zoereply5lp'+chargepoint, 'r')
kamereon_per = json.loads(f.read())
f.close()
with open('/var/www/html/openWB/ramdisk/zoereply4lp'+chargepoint, 'r') as f:
gigya_jwt = json.loads(f.read())
gigya_jwttoken = gigya_jwt['id_token']
with open('/var/www/html/openWB/ramdisk/zoereply5lp'+chargepoint, 'r') as f:
kamereon_per = json.loads(f.read())
kamereonaccountid = kamereon_per['accounts'][0]['accountId']
#print(time_string,'kamereonaccountid',kamereonaccountid)
#

#f = open('/var/www/html/openWB/ramdisk/zoereply6lp'+chargepoint, 'r')
#kamereon_token = json.loads(f.read())
#f.close()
#kamereonaccesstoken = kamereon_token['accessToken']
#print(time_string,'kamereonaccesstoken',kamereonaccesstoken)
#
f = open('/var/www/html/openWB/ramdisk/zoereply7lp'+chargepoint, 'r')
vehic = json.loads(f.read())
f.close()
with open('/var/www/html/openWB/ramdisk/zoereply7lp'+chargepoint, 'r') as f:
vehic = json.loads(f.read())
if len(vin) < 10:
vin = vehic['vehicleLinks'][0]['vin']
print(time_string,'vin wakeup',vin)
payload = {"data":{"type":"ChargingStart","attributes":{"action":"start"}}}
data=json.dumps(payload)
print(time_string, 'vin wakeup', vin)
payload = {"data": {"type": "ChargingStart", "attributes": {"action": "start"}}}
data = json.dumps(payload)
payloadc = {'country': country}
#head1 = 'Bearer ' + kamereonaccesstoken
#headers = {'Content-Type':'application/vnd.api+json','x-gigya-id_token': gigya_jwttoken, 'apikey': kamereonapikey,'x-kamereon-authorization': head1}
headers = {'Content-Type':'application/vnd.api+json','x-gigya-id_token': gigya_jwttoken, 'apikey': kamereonapikey}
reg= kamereonrooturl + '/commerce/v1/accounts/' + kamereonaccountid + '/kamereon/kca/car-adapter/v1/cars/' + vin + '/actions/charging-start'
response=requests.post(reg, params=payloadc, data=data, headers=headers)
responsetext = response.text
f = open('/var/www/html/openWB/ramdisk/zoereply10lp'+chargepoint, 'w')
f.write(str(responsetext))
f.close()
f = open('/var/www/html/openWB/ramdisk/zoereply11lp'+chargepoint, 'w')
f.write(str(reg))
f.write(str(payloadc))
f.write(str(data))
f.write(str(headers))
f.close()
headers = {'Content-Type': 'application/vnd.api+json', 'x-gigya-id_token': gigya_jwttoken, 'apikey': kamereonapikey}
reg = kamereonrooturl + '/commerce/v1/accounts/' + kamereonaccountid + '/kamereon/kca/car-adapter/v1/cars/'
reg += vin + '/actions/charging-start'
response = requests.post(reg, params=payloadc, data=data, headers=headers)
responsetext = response.text
with open('/var/www/html/openWB/ramdisk/zoereply10lp'+chargepoint, 'w') as f:
f.write(str(responsetext))
with open('/var/www/html/openWB/ramdisk/zoereply11lp'+chargepoint, 'w') as f:
f.write(str(reg))
f.write(str(payloadc))
f.write(str(data))
f.write(str(headers))