Skip to content
Merged
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
8 changes: 8 additions & 0 deletions docs/bluetooth_vehicles.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,14 @@ async def main():
asyncio.run(main())
```

## Open/Close Rear Trunk (Bluetooth Only)

`open_rear_trunk()` and `close_rear_trunk()` send an explicit open or close
request, so the result does not depend on the trunk's current state.
`actuate_trunk(Trunk.REAR)` toggles the trunk instead. A `close_rear_trunk()`
acknowledgement means the vehicle accepted the request; check
`closures_state()` or `listen_rear_trunk()` to confirm the trunk closed.

## Get Vehicle Data

You can get data from a `VehicleBluetooth` instance using the individual state
Expand Down
20 changes: 20 additions & 0 deletions tesla_fleet_api/tesla/vehicle/bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,26 @@ async def close_rear_passenger_door(self) -> dict[str, Any]:
)
)

async def open_rear_trunk(self) -> dict[str, Any]:
"""Opens the rear trunk; unlike actuate_trunk, never closes it."""
return await self._sendVehicleSecurity(
UnsignedMessage(
closureMoveRequest=ClosureMoveRequest(
rearTrunk=ClosureMoveType_E.CLOSURE_MOVE_TYPE_OPEN
)
)
)

async def close_rear_trunk(self) -> dict[str, Any]:
"""Closes the rear trunk; unlike actuate_trunk, never opens it."""
return await self._sendVehicleSecurity(
UnsignedMessage(
closureMoveRequest=ClosureMoveRequest(
rearTrunk=ClosureMoveType_E.CLOSURE_MOVE_TYPE_CLOSE
)
)
)

async def query_display_name(self, max_attempts: int = 5) -> str | None:
"""Read the device name via GATT characteristic if available"""
for i in range(max_attempts):
Expand Down
12 changes: 11 additions & 1 deletion tests/test_ble_mocked_closures_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async def test_close_sends_closure_move_close(self) -> None:


class IndividualDoorTests(MockedBleTransportTestCase):
"""The 8 individual door commands - each sets exactly one ``ClosureMoveRequest`` field."""
"""The 8 door and 2 rear trunk commands - each sets one ``ClosureMoveRequest`` field."""

DOORS = [
(
Expand Down Expand Up @@ -140,6 +140,16 @@ class IndividualDoorTests(MockedBleTransportTestCase):
"rearPassengerDoor",
ClosureMoveType_E.CLOSURE_MOVE_TYPE_CLOSE,
),
(
"open_rear_trunk",
"rearTrunk",
ClosureMoveType_E.CLOSURE_MOVE_TYPE_OPEN,
),
(
"close_rear_trunk",
"rearTrunk",
ClosureMoveType_E.CLOSURE_MOVE_TYPE_CLOSE,
),
]

async def test_each_door_command_sets_only_its_own_field(self) -> None:
Expand Down
Loading