Support: SoC Leaf

Alles rund um SoC (Ladezustand des Fahrzeuges). Probleme, Fragen, Fehlfunktionen gehören hier hin
Phase1
Beiträge: 44
Registriert: Do Okt 14, 2021 9:01 pm
Has thanked: 1 time
Been thanked: 6 times

Re: Support: SoC Leaf

Beitrag von Phase1 »

Der Pull Request für V1.9.304 ist ebenfalls abgeschlossen. Ab morgen müsste ein Systemupdate die aktualisierte SoC Abfrage für den Leaf enthalten.
knichiknaxl
Beiträge: 12
Registriert: Do Jun 27, 2024 7:48 pm
Has thanked: 1 time

Re: Support: SoC Leaf

Beitrag von knichiknaxl »

Hab auf Nightly 1.9.304.0 (2025-07-18 07:30:14 +0200 [8d253afa] ) upgedated. Aktualler SoC vom Leaf wird bei mir allerdings nicht angezeigt (0%). Auch reboot hat nichts gebracht.
Debug auf Mode 2 und hier der Output:
2025-07-18 11:25:54: PID: 25477: Lp1: Done (LV1) at 35 main modules/soc_leaf/main.sh
2025-07-18 11:25:54: PID: 25477: Lp1: Starting Python module (LV1) at 33 main modules/soc_leaf/main.sh
2025-07-18 11:25:44: PID: 24064: Lp1: Done (LV1) at 35 main modules/soc_leaf/main.sh
2025-07-18 11:25:44: PID: 24064: Lp1: Starting Python module (LV1) at 33 main modules/soc_leaf/main.sh
Phase1
Beiträge: 44
Registriert: Do Okt 14, 2021 9:01 pm
Has thanked: 1 time
Been thanked: 6 times

Re: Support: SoC Leaf

Beitrag von Phase1 »

knichiknaxl hat geschrieben: Fr Jul 18, 2025 9:26 am Hab auf Nightly 1.9.304.0 (2025-07-18 07:30:14 +0200 [8d253afa] ) upgedated. Aktualler SoC vom Leaf wird bei mir allerdings nicht angezeigt (0%). Auch reboot hat nichts gebracht.
Debug auf Mode 2 und hier der Output:
2025-07-18 11:25:54: PID: 25477: Lp1: Done (LV1) at 35 main modules/soc_leaf/main.sh
2025-07-18 11:25:54: PID: 25477: Lp1: Starting Python module (LV1) at 33 main modules/soc_leaf/main.sh
Hallo @knichiknaxl
main.sh läuft ohne Murren durch. Zwischen den beiden Log Einträgen "Starting Python module ..." und "Done ..." erfolgt in main.sh lediglich der Aufruf des Moduls soc.py (für den Leaf) inkl. Übergabe der Logindaten.

Wie schon hier viewtopic.php?p=111274#p111274 von mir beschrieben, verliert die openWB beim Update auf V1.9.304 möglicherweise die Login-Daten zum NISSAN-Server. Bei meiner openWB war es jedenfalls so. Bitte mal in den Einstellungen für das Leaf-Modul den Usernamen und das Passwort manuell neu eingeben und speichern. Wenn das noch nicht hilft, dann auch noch mal einen Reboot durchführen.
Dd62
Beiträge: 18
Registriert: Sa Okt 05, 2019 3:19 pm
Been thanked: 1 time

Re: Support: SoC Leaf

Beitrag von Dd62 »

Hallo zusammen

Ich habe heute ein frisches RaspiOS Buster installiert und dann OpenWB 1.9.304 hinzuinstalliert. Nach der Installation habe ich die pycarwings2.py verifiziert. Sie enthielt die zwei angepassten Zeilen
BASE_URL = "https://gdcportalgw.its-mo.com/api_v250205_NE/gdc/"
und
req = Request('POST', url=BASE_URL + endpoint, data=params, headers={"Us
er-Agent": ""}).prepare()

Auch bei mir klappt die SOC-Abfrage nicht.

Folgendes fand ich mit tail -n 80 /var/log/openWB.log:

2025-07-19 18:43:01: PID: 12697: Update in progress (LV0) at 43 main /var/www/html/openWB/regel.sh
2025-07-19 18:43:02: at_reboot: lxml installed...
2025-07-19 18:43:02: at_reboot: soc_vwid: python3 secrets installed...
2025-07-19 18:43:09: at_reboot: Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
2025-07-19 18:43:11: at_reboot: Requirement already up-to-date: urllib3 in /home/pi/.local/lib/python3.7/site-packages (2.0.7)
2025-07-19 18:43:11: PID: 12718: Update in progress (LV0) at 43 main /var/www/html/openWB/regel.sh
2025-07-19 18:43:13: at_reboot: version...
2025-07-19 18:43:13: at_reboot: % Total % Received % Xferd Average Speed Time Time Time Current
2025-07-19 18:43:13: at_reboot: Dload Upload Total Spent Left Speed
100 301 100 256 100 45 2370 416 --:--:-- --:--:-- --:--:-- 2787
2025-07-19 18:43:13: at_reboot: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2025-07-19 18:43:13: at_reboot: <html><head>
2025-07-19 18:43:13: at_reboot: <title>404 Not Found</title>
2025-07-19 18:43:13: at_reboot: </head><body>
2025-07-19 18:43:13: PID: 12738: Stopping OpenWB services (LV0)
2025-07-19 18:43:13: at_reboot: <h1>Not Found</h1>
2025-07-19 18:43:13: at_reboot: <p>The requested URL was not found on this server.</p>
2025-07-19 18:43:13: at_reboot: <hr>
2025-07-19 18:43:13: at_reboot: <address>Apache Server at openwb.de Port 443</address>
2025-07-19 18:43:13: at_reboot: </body></html>
2025-07-19 18:43:13: at_reboot: clear warning...
2025-07-19 18:43:13: PID: 12738: OpenWB services stopped (LV0)
2025-07-19 18:43:13: PID: 12738: Starting OpenWB services (LV0)
2025-07-19 18:43:14: PID: 12738: modbus tcp server not running! restarting process (LV0)
2025-07-19 18:43:14: PID: 12738: mqtt handler not running! restarting process (LV0)
2025-07-19 18:43:14: PID: 12738: smart home handler not running! restarting process (LV0)
2025-07-19 18:43:14: PID: 12738: legacy run server is not running. Restarting process (LV0)
2025-07-19 18:43:14: at_reboot: Starting legacy run server
2025-07-19 18:43:14: PID: 12738: Start/restart isss handler in mode daemon. (LV0)
2025-07-19 18:43:14: at_reboot: Failed to stop hostapd.service: Unit hostapd.service not loaded.
2025-07-19 18:43:14: PID: 12789: legacy run server: Changing log level DEBUG -> WARNING
2025-07-19 18:43:14: at_reboot: Failed to stop dnsmasq.service: Unit dnsmasq.service not loaded.
2025-07-19 18:43:15: at_reboot: update broker...
2025-07-19 18:43:16: at_reboot: etprovider...
2025-07-19 18:43:16: at_reboot: not activated, skipping
2025-07-19 18:43:16: at_reboot: fix upload limit...OS Buster
2025-07-19 18:43:17: at_reboot: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
2025-07-19 18:43:17: at_reboot: 2025-07-19 18:43:17: boot done :-)
Traceback (most recent call last):
File "/var/www/html/openWB/modules/soc_leaf/soc.py", line 4, in <module>
import pycarwings2
File "/var/www/html/openWB/modules/soc_leaf/pycarwings2.py", line 85
def encrypt_aes_password(password: str) -> str:
^
SyntaxError: invalid syntax
/usr/lib/python3/dist-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (2.0.7) or chardet (3.0.4) doesn't match a supported version!
RequestsDependencyWarning)
/usr/lib/python3/dist-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (2.0.7) or chardet (3.0.4) doesn't match a supported version!
RequestsDependencyWarning)
Traceback (most recent call last):
File "/var/www/html/openWB/modules/soc_leaf/soc.py", line 4, in <module>
import pycarwings2
File "/var/www/html/openWB/modules/soc_leaf/pycarwings2.py", line 85
def encrypt_aes_password(password: str) -> str:

Die openwb.conf habe ich geprüft. Benutzername und Passwort für meinen Leaf sind enthalten.

Mit
pip install --upgrade urllib3
pip install --upgrade requests
konnte ich die RequestsDependencyWarning zum Verschwinden bringen. Das Problem mit
def encrypt_aes_password(password: str) -> str:
^
SyntaxError: invalid syntax

konnte ich noch nicht lösen. Hat jemand eine Idee?
Phase1
Beiträge: 44
Registriert: Do Okt 14, 2021 9:01 pm
Has thanked: 1 time
Been thanked: 6 times

Re: Support: SoC Leaf

Beitrag von Phase1 »

Hallo Dd62, lange nichts gehört.

so wie ich das interpretiere, gibt es einen Syntax Error für die Funktionsdefinition
def encrypt_aes_password(password: str) -> str:

Ich kann daran erst mal nichts außergewöhnliches erkennen. "Relativ neu" an der Syntax sind die Typdeklarationen : str und -> str.

Typdeklarationen sind aber seit Python 3.5 zulässig. Auf Deiner Installation läuft aber Python 3.7, oder?

Hast Du Zugriff auf den Code in pycarwings2? Falls ja, dann bitte die Zeile 85 mal wie folgt ändern und testen
def encrypt_aes_password(password):
Dd62
Beiträge: 18
Registriert: Sa Okt 05, 2019 3:19 pm
Been thanked: 1 time

Re: Support: SoC Leaf

Beitrag von Dd62 »

Hallo Phase1,

def encrypt_aes_password(password):
bringt uns zumindest einen kleinen Schritt weiter. Jetz wird folgendes angemeckert:

Traceback (most recent call last):
File "/var/www/html/openWB/modules/soc_leaf/soc.py", line 4, in <module>
import pycarwings2
File "/var/www/html/openWB/modules/soc_leaf/pycarwings2.py", line 74, in <module>
from Crypto.Util.Padding import pad
ImportError: No module named Padding
Traceback (most recent call last):
File "/var/www/html/openWB/modules/soc_leaf/soc.py", line 4, in <module>
import pycarwings2
File "/var/www/html/openWB/modules/soc_leaf/pycarwings2.py", line 74, in <module>
from Crypto.Util.Padding import pad
ImportError: No module named Padding
Traceback (most recent call last):
File "/var/www/html/openWB/modules/soc_leaf/soc.py", line 4, in <module>
import pycarwings2
File "/var/www/html/openWB/modules/soc_leaf/pycarwings2.py", line 74, in <module>
from Crypto.Util.Padding import pad
ImportError: No module named Padding

Ich habe im Internet gesucht. Empfohlen wird:
pip3 uninstall crypto
pip3 uninstall pycrypto
pip3 install pycryptodome
pip3 install pycryptodomex

Die Fehlermeldung bleibt unverändert.

Ich frage mich, ob Buster nicht schon zu alt ist für
def encrypt_aes_password(password):
key = AES_KEY.encode("utf-8")
iv = AES_IV.encode("utf-8")
cipher = AES.new(key, AES.MODE_CBC, iv)
padded = pad(password.encode("utf-8"), AES.block_size)
encrypted = cipher.encrypt(padded)
return base64.standard_b64encode(encrypted).decode("utf-8")

In meiner alten openWB 1.9.275 wurde noch folgendes verwendet:
from Crypto.Cipher import Blowfish

def _PKCS5Padding(string):
byteNum = len(string)
packingLength = 8 - byteNum % 8
appendage = chr(packingLength) * packingLength
return string + appendage

c1 = Blowfish.new(ret.baseprm.encode(), Blowfish.MODE_ECB)
packedPassword = _PKCS5Padding(self.password)
encryptedPassword = c1.encrypt(packedPassword.encode())
encodedPassword = base64.standard_b64encode(encryptedPassword)
Phase1
Beiträge: 44
Registriert: Do Okt 14, 2021 9:01 pm
Has thanked: 1 time
Been thanked: 6 times

Re: Support: SoC Leaf

Beitrag von Phase1 »

Hallo Dd62,
mal wieder Crypto.
Also pycarwings3 verlangt Python 3.7 und im setup.py steht: install_requires=[ ... 'pycryptodome', ... ]
pycryptodome ist bei mir auf dem PC installiert und sollte / muss auch auf dem Pi installiert sein.

Nissan hat die API von der veralteten Blowfish Verschlüsselung auf AES umgestellt. Deswegen die neue Funktion encrypt_aes_password(password).
Beide Methoden bedienen sich aus dem gleichen Modul-Paket "Crypto", das mit pip install pycryptodome installiert wird.

(pycryptodomex braucht es nicht. Sollte aber auch nicht schaden, weil damit das Modul-Paket "Cryptodome" installiert wird, das von pycarwings3 nicht genutzt wird.)

Starte unter Python mal
>>> help()
dann
help> modules
Dort sollte dann das Paket "Crypto" aufgelistet sein.
Mit
help> modules Crypto
müssen u.a. folgende Module gelistet werden
Crypto.Cipher.AES
Crypto.Util.Padding

Crypto.Util.Padding wurde lt. Deiner Fehlermeldung aber nicht gefunden und müsste in der Liste dann auch fehlen.
Dd62
Beiträge: 18
Registriert: Sa Okt 05, 2019 3:19 pm
Been thanked: 1 time

Re: Support: SoC Leaf

Beitrag von Dd62 »

Hallo Phase1,

ich hatte zuerst den Verdacht, dass es an den Berechtigungen liegen könnte.
pip3 install pycryptodome hatte ich als User pi ausgeführt.

Ich habe zur Sicherheit alle vier Module als User pi deinstalliert.
pip3 uninstall crypto
pip3 uninstall pycrypto
pip3 uninstall pycryptodome
pip3 uninstall pycryptodomex

Ich hab mich dann als su angemeldet: sudo -i
Nach pip3 install pycryptodome
habe ich dann in der Modulauflistung
Crypto.Cipher.AES
Crypto.Util.Padding

gefunden.

Dennoch wir der Fehler
import pycarwings2
File "/var/www/html/openWB/modules/soc_leaf/pycarwings2.py", line 74, in <module>
from Crypto.Util.Padding import pad
ImportError: No module named Padding

nach wie vor geworfen.
rleidner
Beiträge: 1330
Registriert: Mo Nov 02, 2020 9:50 am
Has thanked: 36 times
Been thanked: 103 times

Re: Support: SoC Leaf

Beitrag von rleidner »

Neustart nach dem Installieren gemacht?
Edit: ich sehe gerade das ist noch 1.9, da bringt der Neustart nichts.
openWB-2 Standard+ | openWB EVU Kit v2 MID| 9,9kWp mit Kostal Plenticore 8.5 plus | VW ID.3, Kia EV6, Smart EQ forfour
Phase1
Beiträge: 44
Registriert: Do Okt 14, 2021 9:01 pm
Has thanked: 1 time
Been thanked: 6 times

Re: Support: SoC Leaf

Beitrag von Phase1 »

Ich habe gerade meine alte lang gediente V1.9 SD-Karte in einen Pi 3 B Rev 1.2 gesteckt.
openWB Version V1.9.304N (01.04.2025)
Kernel: Linux 4.19.66-v7+ GNU/Linux
Python 3.5.3

Der soctimer zählt hoch bis 10.
Die SoC Abfrage vom Leaf läuft dann durch bis zum Sessionaufbau und meldet dann URL not found. Klar, ist ja noch die alte URL.

Code: Alles auswählen

2025-07-20 19:49:29,055 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): gdcportalgw.its-mo.com
2025-07-20 19:49:30,480 - requests.packages.urllib3.connectionpool - DEBUG - https://gdcportalgw.its-mo.com:443 "POST /api_v230317_NE/gdc/InitialApp_v2.php HTTP/1.1" 404 196
2025-07-20 19:49:30,486 - pycarwings2 - DEBUG - Response HTTP Status Code: 404
2025-07-20 19:49:30,486 - pycarwings2 - DEBUG - Response HTTP Response Body: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>
Dann habe ich ein Systemupdate auf openWB Version 1.9.304.0 stable durchgeführt. Das Ergebnis ist das Gleiche. Auch hier noch die alte URL.

Dann habe ich ein Systemupdate auf openWB Version 1.9.304.0 nightly (18.07.2025, also nach PR) durchgeführt.

Der EV SoC Log sieht nun aus wie bei knichiknaxl

Code: Alles auswählen

**** REBOOT ****
2025-07-20 20:05:10: PID: 24622: Lp1: Starting Python module (LV1) at 33 main modules/soc_leaf/main.sh
2025-07-20 20:05:10: PID: 24622: Lp1: Done (LV1) at 35 main modules/soc_leaf/main.sh
2025-07-20 20:05:37: PID: 26354: Lp1: Starting Python module (LV1) at 33 main modules/soc_leaf/main.sh
2025-07-20 20:05:37: PID: 26354: Lp1: Done (LV1) at 35 main modules/soc_leaf/main.sh
und im Debug Log findes sich der gleiche Syntax Fehler wie bei Dd62

Code: Alles auswählen

  File "/var/www/html/openWB/modules/soc_leaf/soc.py", line 4, in <module>
    import pycarwings2
  File "/var/www/html/openWB/modules/soc_leaf/pycarwings2.py", line 85
    def encrypt_aes_password(password: str) -> str:
                                     ^
SyntaxError: invalid syntax
Die Typdeklaration ist markiert, wie ein paar Posts weiter oben schon vermutet. Python 3.5.3 ist anscheinend noch nicht reif für Typdeklarationen.
Da meine SD-Karte eine openWB Version ohne Userzugriff enthält, kann ich pycarwings2 ad hoc nicht editieren und komme hier nicht weiter.

Mit Blick auf viewtopic.php?t=10820 stellt sich nun die Frage, ob die Anpassung von pycarwings2 und eine evtl. weitere Fehlersuche nach dem fehlenden Crypto.Util.Padding noch Sinn macht.

Das leider nicht erfolgreiche Update von pycarwings2 plus das zusätzliche Ubuntu Update dürften die letzten beiden PRs für V1.9 gewesen sein.

Was meint rleidner dazu?
Antworten