Skip to content
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docs/bluetooth_vehicles.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ commands send over BLE:
- `charge_stop()`
- `charge_standard()`
- `charge_max_range()`
- `manual_preconditioning_start()` / `manual_preconditioning_stop()`
- `charge_port_door_open()`
- `charge_port_door_close()`
- `set_charge_limit(percent)`
Expand Down
6 changes: 6 additions & 0 deletions docs/fleet_api_signed_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ Signed commands also include `charge_standard()`, `charge_max_range()`,
door commands. These methods share the same signatures as the Fleet API vehicle
commands, but are sent through the signed-command protocol.

`manual_preconditioning_start()` and `manual_preconditioning_stop()` start and
stop battery preconditioning for fast charging. They are signed-only: the
Fleet API has no REST endpoint for them. Over Bluetooth, `charge_state()`
carries `manual_precon_supported`, `manual_precon_allowed` and
`manual_precon_status`. The command is not yet confirmed on a live vehicle.

`set_scheduled_charging()` and `set_scheduled_departure()` both update the
vehicle's shared `scheduled_charging_mode`. Disabling one mode while the other
is active can turn scheduled charging/departure off entirely, so callers that
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies = [
"aiolimiter>=1",
"cryptography>=43",
"protobuf>=6.33.5",
"tesla-protocol>=6.1.0,<7",
"tesla-protocol>=6.3.2,<7",
"bleak>=0.22",
"bleak-retry-connector>=3.9",
]
Expand Down
29 changes: 29 additions & 0 deletions tesla_fleet_api/tesla/vehicle/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
HvacSeatHeaterActions,
HvacSeatCoolerActions,
HvacSetPreconditioningMaxAction,
ManualPreconditioningAction,
HvacSteeringWheelHeaterAction,
HvacTemperatureAdjustmentAction,
GetNearbyChargingSites,
Expand Down Expand Up @@ -1489,6 +1490,34 @@ async def honk_horn(self) -> dict[str, Any]:
)
)

async def manual_preconditioning_start(self) -> dict[str, Any]:
"""Starts preconditioning the battery for fast charging.

The vehicle rejects this with a ``START_MANUAL_PRECON_*`` reason when
the battery is low, a DC charger is connected, navigation to a
Supercharger is active, or the vehicle does not support it. Not yet
confirmed on a live vehicle.
"""
return await self._sendInfotainment(
Action(
vehicleAction=VehicleAction(
manualPreconditioningAction=ManualPreconditioningAction(
start=Void()
)
)
)
)

async def manual_preconditioning_stop(self) -> dict[str, Any]:
"""Stops manual battery preconditioning. Not yet confirmed on a live vehicle."""
return await self._sendInfotainment(
Action(
vehicleAction=VehicleAction(
manualPreconditioningAction=ManualPreconditioningAction(stop=Void())
)
)
)

async def media_next_fav(self) -> dict[str, Any]:
"""Advances media player to next favorite track."""
return await self._sendInfotainment(
Expand Down
21 changes: 21 additions & 0 deletions tests/test_ble_charging_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,24 @@ async def test_charge_port_door_close_sends_rke_close(self) -> None:
unsigned.closureMoveRequest.chargePort,
ClosureMoveType_E.CLOSURE_MOVE_TYPE_CLOSE,
)


class ManualPreconditioningTests(MockedBleTransportTestCase):
async def test_manual_preconditioning_start_sends_start_void(self) -> None:
vehicle, send = self.make_vehicle()
send.return_value = infotainment_action_ok_reply()

result = await vehicle.manual_preconditioning_start()

self.assertEqual(result, {"response": {"result": True, "reason": ""}})
action = _decode_vehicle_action(vehicle, send.await_args.args[0])
self.assertTrue(action.manualPreconditioningAction.HasField("start"))

async def test_manual_preconditioning_stop_sends_stop_void(self) -> None:
vehicle, send = self.make_vehicle()
send.return_value = infotainment_action_ok_reply()

await vehicle.manual_preconditioning_stop()

action = _decode_vehicle_action(vehicle, send.await_args.args[0])
self.assertTrue(action.manualPreconditioningAction.HasField("stop"))
Loading