Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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
47 changes: 33 additions & 14 deletions hyundai_kia_connect_api/KiaUvoApiCA.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def get_vehicles(self, token: Token) -> list[Vehicle]:
engine_type=entry_engine_type,
timezone=self.data_timezone,
dtc_count=entry["dtcCount"],
gen_type=entry.get("genType"),
)
result.append(vehicle)
return result
Expand Down Expand Up @@ -983,7 +984,6 @@ def _get_charge_limits(self, token: Token, vehicle: Vehicle) -> dict:
def set_charge_limits(
self, token: Token, vehicle: Vehicle, ac: int, dc: int
) -> str:
url = self.API_URL + "evc/setsoc"
headers = self.API_HEADERS
headers["accessToken"] = token.access_token
headers["vehicleId"] = vehicle.id
Expand All @@ -993,19 +993,38 @@ def set_charge_limits(
headers["priority"] = "u=1, i"
headers["Referer"] = "https://kiaconnect.ca/remote/"

payload = {
"tsoc": [
{
"plugType": 0,
"level": dc,
},
{
"plugType": 1,
"level": ac,
},
],
"pin": token.pin,
}
if vehicle.gen_type == "G3":
# Gen3 Vehicles (like IONIQ 9) use a different endpoint and payload
url = self.API_URL + "v2/ev/reserv/socset"
payload = {
"targetSOClist": [
{
"plugType": 0,
"targetSOClevel": dc,
},
{
"plugType": 1,
"targetSOClevel": ac,
},
],
"pin": token.pin,
}
else:
# Legacy Gen1/Gen2 Payload
url = self.API_URL + "evc/setsoc"
payload = {
"tsoc": [
{
"plugType": 0,
"level": dc,
},
{
"plugType": 1,
"level": ac,
},
],
"pin": token.pin,
}

_LOGGER.debug(
f"{DOMAIN} - Planned set_charge_limits payload {self._mask_sensitive_data(payload)}"
Expand Down
3 changes: 3 additions & 0 deletions hyundai_kia_connect_api/Vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class Vehicle:
# Not part of the API, enabled in our library for scanning.
enabled: bool = True

# Generation type (e.g. "G3")
gen_type: str = None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lets use generation two fields up for this.


# Shared (EV/PHEV/HEV/IC)
# General
_total_driving_range: float = None
Expand Down
Loading