Re: SOC Modul Porsche Taycan
Verfasst: Sa Jul 31, 2021 6:17 pm
Der Porsche-Server war die letzte Zeit auch etwas buggy, mag sein, dass es nicht an OpenWB lag…
Code: Alles auswählen
Error from EVCC: 2022/07/14 21:25:25 invalid character '<' looking for beginning of value (LV0))
Ich habe mich doof ausgedrückt. Natürlich wäre das Auslesen des SOC per Ladekabel (so wie es der Porsche-Lader kann) die beste Lösung.Mit der OpenWB wirst du wohl über das Kabel keine Daten bekommen, sondern nur über das Internet von den Porsche-Servern.
Code: Alles auswählen
import asyncio
import sys
from sys import argv
from pyporscheconnectapi.connection import Connection
from pyporscheconnectapi.client import Client
email = argv[1]
password = argv[2]
vin = argv[3]
async def vehicles():
conn = Connection(email, password)
data = await conn.get(f"https://api.porsche.com/service-vehicle/se/sv_SE/vehicle-data/{vin}/stored")
global batterysoc
batterysoc = data['batteryLevel']['value']
await conn.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(vehicles())
sys.stdout.write(str(batterysoc))
sys.exit(0)
Code: Alles auswählen
import sys
import asyncio
from pyporscheconnectapi.connection import Connection
from pyporscheconnectapi.client import Client
from sys import argv
import logging
# logging.basicConfig()
# logging.root.setLevel(logging.DEBUG)
email = argv[1]
password = argv[2]
vin1 = argv[3]
async def vehicles() -> None:
conn = Connection(email, password)
client = Client(conn)
vehicles = await client.getVehicles()
for vehicle in vehicles:
# print(
# f"VIN: {vehicle['vin']}, Model: {vehicle['modelName']}, Year: {vehicle['modelType']['year']}"
# )
mf = ["BATTERY_LEVEL", "LOCK_STATE_VEHICLE"]
measurements = "mf=" + "&mf=".join(mf)
data = await conn.get(
f"https://api.ppa.porsche.com/app/connect/v1/vehicles/{vin1}?{measurements}"
)
global soc
soc = (next((x for x in data["measurements"] if x["key"] == mf[0]), None))[
"value"
]["percent"]
await conn.close()
if __name__ == "__main__":
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(vehicles())
except KeyboardInterrupt:
pass
sys.stdout.write(str(soc))
sys.exit(0)