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

Mercedes EQ SoC Modul #823

Merged
merged 8 commits into from
Jan 2, 2021
Merged

Mercedes EQ SoC Modul #823

merged 8 commits into from
Jan 2, 2021

Conversation

DetMoerk
Copy link
Contributor

First Beta of a Mercedes EQ SoC Module ussing the API at https://developer.mercedes-benz.com/products/electric_vehicle_status.
As every User has to create his own account at developer.mercedes-benz.com (BYOCAR= Bring your own Car), configuration has some traps. I will try to bring a step-by-step documentation in openwb Forum and here.
Requirements:

  1. Mercedes Me Account
  2. FIN (VIN) of own Car
  3. Make sure that your car has "Schnittstelle Drittanbieter: Fahrzeugdaten" active. Got to Mercedes Me App/Garage/Diensteverwaltung/Komfort.

Steps to get a API Access:
1. Go to the Mercedes Developer Site

grafik

2. Login (upper right corner) using your MercedesMe Credentials

grafik

3. Get Access to The API

grafik

4. Choose Purchase Model "Get for free"

grafik

5. Choose Package "BYOCAR"

grafik

6. Create an App (this looks different, as I still have Apps in MercedesMe)

grafik

7. Fill Application Name and Business Purpose and choose "Create" button

grafik

8. after Confirm you will see your new Application (OPENWBSOC)

grafik

9. Subscribe an use "View in Console"

grafik

10. Change Redirect URLs

You will get an "App ID", "Client ID" and "Client Secret". You'll have to fill in the Value(s) for rediect URL(s).
The redirect URL must contain the IP Address (marked as IPopenWB) in the picture. You can also add additional Redirect URLs for example with a hostname (place the hostname of your openWB instead of hostname) as you see in the second line.
To use the SoC Api also for the second LP, use a Redirect URL (like in line 3) with the matching callback function (callback_lp2.php)
Make sure you use same protocol as used by the openWB (here http://).
grafik

Note the Values in "Client ID" and "Client Secret". You will need these and the according Redirect URL in the openWV LP Configuration

11: Configure openWB LP (Ladepunkt)

Got to Einstellungen/Modulkonfiguration/Ladepunkte
grafik

12. Choose Mercedes EQ (BETA!!!) from the List

grafik

13. Fill the values "Client ID", "Client Secret", "Fahrzeug Ident", "Callback" with the matching Values from Step 10

grafik

14. Save the Values

Go tot the Bottom of the page and press "Speichern" Button
grafik

15. Go back to the Ladepunkt and press the "HIER bei Mercedes Me anmelden" link.

This will open an new Window, reach out to the Mercedes API (if Asked, log in with your Mercedes Me ID)and save the needed Access token inside the openWB Config.
grafik

You can close that empty window,

Finally your configuration is done.

Erweiterung curl VZ auf Ausgabe mit Zeilennummern
Beta Test des Mercedes EQ Soc von Achim. Leichte Änderungen zum Stand von Achim. Verwendung der container Ressource um SoC und Range in eimen Aufruf zu erhalten, zur späteren Verwendung des Range Wertes. MArkierung in der LP Konfig als BETA!!!. Genaue Anleitung muss noch erstellt werden.
@DetMoerk
Copy link
Contributor Author

DetMoerk commented Dec 28, 2020

May solve Issue #687

modules/soc_eq/callback_lp2.php Outdated Show resolved Hide resolved
modules/soc_eqlp2/main.sh Outdated Show resolved Hide resolved
Copy Paste Errors in Comments fixed
less -N stays in less after executing the curl. cat -n ends in Shell after curl.
@DetMoerk
Copy link
Contributor Author

DetMoerk commented Dec 28, 2020

Kann es sein, dass es für LP3-LP8 (noch) keine SoC Module gibt? Aus der aktuellen Verzeichnisstruktur scheint das auch bei den anderen SoC Modulen hard coded nur LP1 und LP2 zu sein.

@benderl
Copy link
Collaborator

benderl commented Dec 28, 2020

Ja, das stimmt. Die Module wurden bzw. werden nach und nach aber umgeschrieben.

soctimer=$((soctimer+1))
echo $soctimer > $soctimerfile
else
export soc_eq_client_id soc_eq_client_secret soc_eq_vin soc_file CHARGEPOINT
Copy link
Collaborator

Choose a reason for hiding this comment

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

Diese Einstellungen sollten nicht im Environment exportiert werden. Besser als Parameter im Aufruf des soc.py angeben.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ist im letzten Commit umgesetzt

echo $soctimer > $soctimerfile
else
export soc_eq_client_id soc_eq_client_secret soc_eq_vin soc_file CHARGEPOINT
/var/www/html/openWB/modules/soc_eq/soc.py
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bitte an den Aufruf der soc.py ein "&" anhängen, damit das Skript im Hintergrund ausgeführt wird und nicht die Regelschleife ausbremst.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gibt es ein SoC Modul, das als gutes Beispiel dienen kann? Ich hab den Code in einem Beitrag im Forum bekommen und bei mir eingebaut. Das hat soweit funktioniert, ein paar Blicke habe ich schon in andere SoC Module geworfen, aber da sind die Implementierungen auch sehr unterschiedlich.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Da hast Du Recht, das ist teilweise sehr unterschiedlich. Schau mal dort rein, das entspricht dem, was mir als "Standard" vorschwebt:

sudo python3 $MODULEDIR/kiasoc.py $kia_email $kia_password $kia_pin $kia_vin $socfile >> $LOGFILE &

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ist analog realisiert, allerdings verstehe ich and er Stelle den sudo nicht. Ist der zwingend? Bei meinem Modul geht das auch ohne sudo, allerdings als Installation auf einem meiner Raspis.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Welchen OS User verwendet denn eine openWB Installation auf dem Raspi? Ich hatte heute ein Thema mit Userberechtigungen auf Files um die Token zu persistieren. Die Callback URL ist bei mir ein php Script, welches dann ein Python Script aufruft. Die laufen auf meinem Raspi wie üblich unter dem User www-data. Die openWB Verzeichnisse liegen bei mir aber unter dem User pi.
VG
Det

Copy link
Collaborator

Choose a reason for hiding this comment

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

OpenWB nutzt sudo häufig und auch meiner Meinung nach zu oft. Alle Prozesse laufen als user pi. Mit Version 2.x werden die benötigten Rechte detaillierter geprüft. Wenn Dein Modul ohne sudo läuft, kann es gerne weggelassen werden.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Läuft der Apache auch als User pi? Ansonsten müssen die leeren Dateien zum Persistieren der Token und der Expire Time mit user pi und mode 666 angelegt sein, damit der apache im callback auch darauf zugreifen darf.

VG
Det

Changed main.sh and soc.py to write to logfile. soc.py is called with arguments instead of exporting
@benderl
Copy link
Collaborator

benderl commented Dec 30, 2020

Hallo @DetMoerk ,
Danke für das Modul und die ganzen Anpassungen. Siehst Du noch eine Möglichkeit, die callback Handler zu verallgemeinern, damit ein Skript für alle LP genutzt werden kann? Falls nicht, kann der PR durchaus jetzt gemerged werden. Vielleicht finden wir später gemeinsam eine Lösung.
Die Anleitung kopiere ich dann kommende Woche in das Wiki und füge einen Link direkt bei der Modulauswahl ein.

@DetMoerk
Copy link
Contributor Author

Hi, warte mal noch mit mergen, ich hab noch ne Änderung die ich nicht committed habe. Denke heute im Lauf des Nachmittags werde ich das noch fertig bekommen, ist hauptsächlich Logging und ne Ausgabe wenn der Auth Callback erfolgreich war. Die ist aber noch nicht schön, da muss ich noch mal ran.
Die Ladepunkte zusammen zu führen sehe ich gerade keine Möglichkeit, das wäre dann was für die nächste Version des Moduls ;-)

VG
Det

@DetMoerk
Copy link
Contributor Author

Eine Frage habe ich auch noch, die API bringt auch eine Rangeelectric Wert zurück. Aktuell schreibe ich den nicht weg, aber wenn das auf der openWB Seite noch irgendwo dargestellt werden kann, würde ich das auch noch in ne Datei schreiben.

VG
Det

@benderl
Copy link
Collaborator

benderl commented Dec 30, 2020

Das ist aktuell nicht vorgesehen. Kann man in Version 2.x drüber diskutieren, wenn das eine Mehrzahl der SoC Module ermöglicht.
Deine Beschreibung ist jetzt auch im Wiki: https://github.com/snaptec/openWB/wiki/EV-SoC-Modul-Mercedes-EQ
Bitte füge doch den Link in der modulconfiglp.php als "alert-info" Block ein.

Dokumentation in den modulconfiglp eingebaut.
@DetMoerk
Copy link
Contributor Author

@benderl: Ichhabe die Doku verlinkt, leider habe ich übersehen, dass es als alert-info sein soll.
Bei mir sieht es jetzt so aus.
Wäre das auch OK?
grafik
Wenn Ja, kannst du gerne mergen.

@benderl
Copy link
Collaborator

benderl commented Dec 30, 2020

Sieht auch gut aus.

@snaptec
Kannst Du dann bitte mergen?

@snaptec snaptec merged commit b4f4b74 into snaptec:master Jan 2, 2021
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.

3 participants