Skip to content

Commit

Permalink
Fix encoding of the control_windows command
Browse files Browse the repository at this point in the history
  • Loading branch information
nanomad committed Jan 30, 2024
1 parent 45ac2d8 commit b5ac9e7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/saic_ismart_client_ng/api/vehicle/windows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
class SaicVehicleWindowsApi(SaicVehicleApi):

async def control_sunroof(self, vin: str, *, should_open: bool) -> VehicleControlResp:
return await self.control_window(vin, should_open=should_open, window_id=VehicleWindowId.SUNROOF)
return await self.control_windows(vin, should_open=should_open, windows=[VehicleWindowId.SUNROOF])

async def close_driver_window(self, vin: str) -> VehicleControlResp:
return await self.control_window(vin, should_open=False, window_id=VehicleWindowId.DRIVER)
return await self.control_windows(vin, should_open=False, windows=[VehicleWindowId.DRIVER])

async def control_window(self, vin: str, *, should_open: bool, window_id: VehicleWindowId) -> VehicleControlResp:
async def control_windows(self, vin: str, *, should_open: bool, windows: [VehicleWindowId]) -> VehicleControlResp:
requested_windows = [w.value.value for w in windows]
rcv_params = []
for i in [
VehicleWindowId.SUNROOF,
Expand All @@ -22,13 +23,12 @@ async def control_window(self, vin: str, *, should_open: bool, window_id: Vehicl
VehicleWindowId.WINDOW_3,
VehicleWindowId.WINDOW_4
]:
if i == window_id:
if i.value.value in requested_windows:
rcv_params.append(RvcParams(i.value, b'\x01'))
else:
rcv_params.append(RvcParams(i.value, b'\x00'))

param = RvcParams(RvcParamsId.WINDOW_OPEN_CLOSE, b'\x03' if should_open else b'\x00')
rcv_params.append(param)
rcv_params.append(RvcParams(RvcParamsId.WINDOW_OPEN_CLOSE, b'\x03' if should_open else b'\x00'))

request = VehicleControlReq(
rvc_req_type=RvcReqType.WINDOWS,
Expand Down

0 comments on commit b5ac9e7

Please sign in to comment.