diff --git a/docs/bluetooth_vehicles.md b/docs/bluetooth_vehicles.md index 67e6f51..0877c21 100644 --- a/docs/bluetooth_vehicles.md +++ b/docs/bluetooth_vehicles.md @@ -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)` diff --git a/docs/fleet_api_signed_commands.md b/docs/fleet_api_signed_commands.md index fd88c4d..870aa4b 100644 --- a/docs/fleet_api_signed_commands.md +++ b/docs/fleet_api_signed_commands.md @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 500cf86..3ba3ba1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", ] diff --git a/tesla_fleet_api/tesla/vehicle/commands.py b/tesla_fleet_api/tesla/vehicle/commands.py index c978917..813244e 100644 --- a/tesla_fleet_api/tesla/vehicle/commands.py +++ b/tesla_fleet_api/tesla/vehicle/commands.py @@ -107,6 +107,7 @@ HvacSeatHeaterActions, HvacSeatCoolerActions, HvacSetPreconditioningMaxAction, + ManualPreconditioningAction, HvacSteeringWheelHeaterAction, HvacTemperatureAdjustmentAction, GetNearbyChargingSites, @@ -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( diff --git a/tests/test_ble_charging_commands.py b/tests/test_ble_charging_commands.py index 6379222..c77ded1 100644 --- a/tests/test_ble_charging_commands.py +++ b/tests/test_ble_charging_commands.py @@ -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"))