Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions pyporscheconnectapi/vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,7 @@ def doors_and_lids(self) -> bool:
def tire_pressure_status(self) -> bool:
"""Return true if tire pressure is within the tolerances."""
tire_pressure_status = self.data.get("TIRE_PRESSURE") or {}
differences = [
abs(tire_pressure_status[key]["differenceBar"])
for key in tire_pressure_status
if key.endswith("Tire")
]
differences = [abs(tire_pressure_status[key]["differenceBar"]) for key in tire_pressure_status if key.endswith("Tire")]
if not differences:
return True
return max(differences) <= TIRE_PRESSURE_TOLERANCE
Expand Down Expand Up @@ -373,15 +369,24 @@ def _update_vehicle_data(self) -> None:
# This attribute gives the chargingRate in the odd unit kilometers per minute. We add a km/h attribute.
mdata["CHARGING_RATE"]["chargingRate-kph"] = mdata["CHARGING_RATE"]["chargingRate"] * 60

if "CHARGING_SUMMARY" in mdata and mdata.get("CHARGING_SUMMARY", {}).get("mode") == "PROFILE":
if "CHARGING_SUMMARY" in mdata and mdata.get("CHARGING_SUMMARY", {}).get("targetSoC") is not None:
# Newer payloads expose the active target SoC directly.
mdata["CHARGING_SUMMARY"]["minSoC"] = mdata["CHARGING_SUMMARY"]["targetSoC"]

elif "CHARGING_SUMMARY" in mdata and mdata.get("CHARGING_SUMMARY", {}).get("mode") == "PROFILE":
# If charging profiles are enabled, get minSoC from this dict.
mdata["CHARGING_SUMMARY"]["minSoC"] = mdata["CHARGING_SUMMARY"]["chargingProfile"]["minSoC"]

if "DEPARTURES" in mdata and mdata.get("CHARGING_SETTINGS", {}).get("targetSoc"):
if "DEPARTURES" in mdata and mdata.get("CHARGING_SETTINGS", {}).get("targetSoc") and mdata.get("CHARGING_SUMMARY", {}).get("targetSoC") is None:
# If charging on departures are enabled, get minSoC from the CHARGING_SETTINGS dict.
mdata["CHARGING_SUMMARY"]["minSoC"] = mdata["CHARGING_SETTINGS"]["targetSoc"]

if "DEPARTURES" not in mdata and "CHARGING_SUMMARY" in mdata and mdata.get("CHARGING_SUMMARY", {}).get("mode") == "DIRECT":
if (
"DEPARTURES" not in mdata
and "CHARGING_SUMMARY" in mdata
and mdata.get("CHARGING_SUMMARY", {}).get("mode") == "DIRECT"
and mdata.get("CHARGING_SUMMARY", {}).get("minSoC") is None
):
# If direct charging is ongoing, minSoC is set to None in the API. We set it till 100 instead.
mdata["CHARGING_SUMMARY"]["minSoC"] = 100

Expand Down
Loading