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

SOC-Modul Renault #638

Closed
wants to merge 2 commits into from
Closed

SOC-Modul Renault #638

wants to merge 2 commits into from

Conversation

rleidner
Copy link
Contributor

SOC Modul for Renault vehicles.
tested with Zoe account - SOC Update works.
Wakeup part not migrated - not sure what that exactly does.

Copy link
Contributor

@LKuemmel LKuemmel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Der Umstieg von der Urllib auf Requests bietet einige Vorteile:
Requests bietet ein Highlevel Client Interface. Dadurch ist es leichter zu lesen und anzuwenden. Außerdem benutzt Requests den Python-Logger. Über Session-Hooks werden die Http-Antworten automatisch geloggt.
Der Code wird dadurch um einiges kürzer und verständlicher.

Comment on lines +152 to +171
payload = {'country': country}
data = urllib.parse.urlencode(payload)
data = data.encode('Big5')
reg = urllib.request.Request(kamereonrooturl + '/commerce/v1/accounts/' +
kamereonaccountid + '/vehicles?' + data.decode("utf-8"))
reg.add_header('x-gigya-id_token', gigya_jwttoken)
reg.add_header('apikey', kamereonapikey)
dmp = {}
dmp['payload'] = str(payload)
dmp['data'] = data.decode("utf-8")
dmp['reg'] = str(reg)
dump_json(dmp, "soc_renault_7_request_vh" + str(vehicle))
response = urllib.request.urlopen(reg)
responsetext = response.read()
vehic = json.loads(responsetext)
dmp = {}
dmp['response'] = str(response)
dmp['responsetext'] = str(responsetext)
dmp['vehic'] = str(vehic)
dump_json(dmp, "soc_renault_7_reply_vh" + str(vehicle))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
payload = {'country': country}
data = urllib.parse.urlencode(payload)
data = data.encode('Big5')
reg = urllib.request.Request(kamereonrooturl + '/commerce/v1/accounts/' +
kamereonaccountid + '/vehicles?' + data.decode("utf-8"))
reg.add_header('x-gigya-id_token', gigya_jwttoken)
reg.add_header('apikey', kamereonapikey)
dmp = {}
dmp['payload'] = str(payload)
dmp['data'] = data.decode("utf-8")
dmp['reg'] = str(reg)
dump_json(dmp, "soc_renault_7_request_vh" + str(vehicle))
response = urllib.request.urlopen(reg)
responsetext = response.read()
vehic = json.loads(responsetext)
dmp = {}
dmp['response'] = str(response)
dmp['responsetext'] = str(responsetext)
dmp['vehic'] = str(vehic)
dump_json(dmp, "soc_renault_7_reply_vh" + str(vehicle))
payload = {'country': country}
vehic=req.get_http_session().post(f"{kamereonrooturl}/commerce/v1/accounts/{kamereonaccountid}/vehicles", headers={'x-gigya-id_token': gigya_jwttoken,
'apikey': kamereonapikey}, data=json.dumps(payload)).json()

Der Request sieht dann so aus (ich kann es nicht testen, evtl muss zum Post noch ein verify=False hinzu)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Die Änderung ist bestimmt sinnvoll. und ich würde es übernehmen, wenn ich könnte.
Ich kann es aber leider nicht mehr testen;
Jarry hatte mich gebeten den Renault-Modul zu migrieren und dazu seinen myRenault-Account nach Passwort-Änderung geteilt.
Nachdem es lief, ist das Passwort wieder geändert.

Solche substantiellen Änderungen sollte auch jemand machen, der dauerhaften Zugriff auf den entsprechende Fahrzeug-Account hat.

Also erst mal "as-is" mergen oder es bleibt hat ein PR bis sich jemand findet.

@benderl
Copy link
Contributor

benderl commented Nov 14, 2022

Bitte auch auf empfohlene Namenskonventionen achten.
Beispiel: userid sollte in user_id umbenannt werden.

@benderl benderl added the ui depends on changes in ui repository label Nov 14, 2022
@LKuemmel
Copy link
Contributor

Jarry hat mir freundlicherweise seine Account-Daten zur Verfügung gestellt, ich arbeite aktuell an der Umstellung auf das requests-Modul.

@rleidner
Copy link
Contributor Author

Vielen Dank, Lena.

@benderl benderl removed the ui depends on changes in ui repository label Nov 24, 2022
@LKuemmel LKuemmel mentioned this pull request Dec 12, 2022
@LKuemmel
Copy link
Contributor

In PR #689 enthalten

@LKuemmel LKuemmel closed this Dec 29, 2022
@rleidner rleidner deleted the soc_renault branch April 7, 2023 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants