Skip to content

Commit

Permalink
fix: seat heat/cool settings for USA vehicles (#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeshaw authored Dec 24, 2024
1 parent c131587 commit 997d8a2
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 68 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- Hyundai / Kia Connect version:
- Python version:
- Operating System:
- Hyundai / Kia Connect version:
- Python version:
- Operating System:

### Description

Expand Down
122 changes: 57 additions & 65 deletions hyundai_kia_connect_api/KiaUvoApiUSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,59 @@ def lock_action(self, token: Token, vehicle: Vehicle, action) -> str:

return response.headers["Xid"]

def _seat_settings(self, level) -> dict:
# See const.SEAT_STATUS for the list and descriptions of levels.
#
# The values were determined empirically, see https://github.com/Hyundai-Kia-Connect/kia_uvo/issues/718
if level == 8: # High heat
return {
"heatVentType": 1,
"heatVentLevel": 4,
"heatVentStep": 1,
}
elif level == 7: # Medium heat
return {
"heatVentType": 1,
"heatVentLevel": 3,
"heatVentStep": 2,
}
elif level == 6: # Low heat
return {
"heatVentType": 1,
"heatVentLevel": 2,
"heatVentStep": 3,
}
elif level == 5: # High cool
return {
"heatVentType": 2,
"heatVentLevel": 4,
"heatVentStep": 1,
}
elif level == 4: # Medium cool
return {
"heatVentType": 2,
"heatVentLevel": 3,
"heatVentStep": 2,
}
elif level == 3: # Low cool
return {
"heatVentType": 2,
"heatVentLevel": 2,
"heatVentStep": 3,
}
elif level == 1: # Generically on, let's assume high heat
return {
"heatVentType": 1,
"heatVentLevel": 4,
"heatVentStep": 1,
}
else: # Off
return {
"heatVentType": 0,
"heatVentLevel": 1,
"heatVentStep": 0,
}

def start_climate(
self, token: Token, vehicle: Vehicle, options: ClimateRequestOptions
) -> str:
Expand Down Expand Up @@ -668,72 +721,11 @@ def start_climate(
or options.rear_left_seat is not None
or options.rear_right_seat is not None
):
if options.front_left_seat is None:
options.front_left_seat = 0
if options.front_right_seat is None:
options.front_right_seat = 0
if options.rear_left_seat is None:
options.rear_left_seat = 0
if options.rear_right_seat is None:
options.rear_right_seat = 0

front_left_heatVentType = 0
front_right_heatVentType = 0
rear_left_heatVentType = 0
rear_right_heatVentType = 0
front_left_heatVentLevel = 0
front_right_heatVentLevel = 0
rear_left_heatVentLevel = 0
rear_right_heatVentLevel = 0

# heated
if options.front_left_seat in (6, 7, 8):
front_left_heatVentType = 1
front_left_heatVentLevel = options.front_left_seat - 4
if options.front_right_seat in (6, 7, 8):
front_right_heatVentType = 1
front_right_heatVentLevel = options.front_right_seat - 4
if options.rear_left_seat in (6, 7, 8):
rear_left_heatVentType = 1
rear_left_heatVentLevel = options.rear_left_seat - 4
if options.rear_right_seat in (6, 7, 8):
rear_right_heatVentType = 1
rear_right_heatVentLevel = options.rear_right_seat - 4

# ventilated
if options.front_left_seat in (3, 4, 5):
front_left_heatVentType = 2
front_left_heatVentLevel = options.front_left_seat - 1
if options.front_right_seat in (3, 4, 5):
front_right_heatVentType = 2
front_right_heatVentLevel = options.front_right_seat - 1
if options.rear_left_seat in (3, 4, 5):
rear_left_heatVentType = 2
rear_left_heatVentLevel = options.rear_left_seat - 1
if options.rear_right_seat in (3, 4, 5):
rear_right_heatVentType = 2
rear_right_heatVentLevel = options.rear_right_seat - 1
body["remoteClimate"]["heatVentSeat"] = {
"driverSeat": {
"heatVentType": front_left_heatVentType,
"heatVentLevel": front_left_heatVentLevel,
"heatVentStep": 1,
},
"passengerSeat": {
"heatVentType": front_right_heatVentType,
"heatVentLevel": front_right_heatVentLevel,
"heatVentStep": 1,
},
"rearLeftSeat": {
"heatVentType": rear_left_heatVentType,
"heatVentLevel": rear_left_heatVentLevel,
"heatVentStep": 1,
},
"rearRightSeat": {
"heatVentType": rear_right_heatVentType,
"heatVentLevel": rear_right_heatVentLevel,
"heatVentStep": 1,
},
"driverSeat": self._seat_settings(options.front_left_seat),
"passengerSeat": self._seat_settings(options.front_right_seat),
"rearLeftSeat": self._seat_settings(options.rear_left_seat),
"rearRightSeat": self._seat_settings(options.rear_right_seat),
}
_LOGGER.debug(f"{DOMAIN} - Planned start_climate payload: {body}")
response = self.post_request_with_logging_and_active_session(
Expand Down

0 comments on commit 997d8a2

Please sign in to comment.