Skip to content

Commit 8021021

Browse files
committed
Fix valet
1 parent c6efcb3 commit 8021021

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

tesla_fleet_api/tesla/vehicle/commands.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,14 +1174,16 @@ async def set_temps(
11741174
)
11751175
)
11761176

1177-
async def set_valet_mode(self, on: bool, password: str | int) -> dict[str, Any]:
1177+
async def set_valet_mode(self, on: bool, password: str | int | None = None) -> dict[str, Any]:
11781178
"""Turns on Valet Mode and sets a four-digit passcode that must then be entered to disable Valet Mode."""
1179+
action = VehicleControlSetValetModeAction(on=on)
1180+
if password is not None:
1181+
action.password = str(password)
1182+
11791183
return await self._sendInfotainment(
11801184
Action(
11811185
vehicleAction=VehicleAction(
1182-
vehicleControlSetValetModeAction=VehicleControlSetValetModeAction(
1183-
on=on, password=str(password)
1184-
)
1186+
vehicleControlSetValetModeAction=action
11851187
)
11861188
)
11871189
)

tesla_fleet_api/tesla/vehicle/fleet.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,16 @@ async def set_temps(
475475
)
476476

477477
async def set_valet_mode(
478-
self, on: bool, password: str | int
478+
self, on: bool, password: str | int | None = None
479479
) -> dict[str, Any]:
480480
"""Turns on Valet Mode and sets a four-digit passcode that must then be entered to disable Valet Mode."""
481+
json_data: dict[str,Any] = {"on": on}
482+
if password is not None:
483+
json_data["password"] = str(password)
481484
return await self._request(
482485
Method.POST,
483486
f"api/1/vehicles/{self.vin}/command/set_valet_mode",
484-
json={"on": on, "password": str(password)},
487+
json=json_data,
485488
)
486489

487490
async def set_vehicle_name(

0 commit comments

Comments
 (0)