You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Detailed Examples for Using Bluetooth for Vehicles
1
+
# Bluetooth for Vehicles
2
2
3
-
This document provides detailed examples for using the `TeslaBluetooth` class to interact with Tesla vehicles using Bluetooth.
3
+
This document provides detailed examples for using Bluetooth for vehicles.
4
4
5
-
## Example 1: Discovering Tesla Vehicles
5
+
## Initialize TeslaBluetooth
6
6
7
-
The following example demonstrates how to discover Tesla vehicles using Bluetooth:
7
+
The `TeslaBluetooth` class provides methods to interact with Tesla vehicles using Bluetooth. Here's a basic example to initialize the `TeslaBluetooth` class and discover nearby Tesla vehicles:
8
8
9
9
```python
10
10
import asyncio
@@ -21,72 +21,78 @@ async def main():
21
21
asyncio.run(main())
22
22
```
23
23
24
-
## Example 2: Querying Display Name
24
+
## Create VehicleBluetooth Instance
25
25
26
-
The following example demonstrates how to query the display name of a Tesla vehicle using Bluetooth:
26
+
You can create a `VehicleBluetooth` instance using the `TeslaBluetooth` class. Here's a basic example to create a `VehicleBluetooth` instance and set the private key from a file:
27
27
28
28
```python
29
29
import asyncio
30
-
from bleak import BleakScanner
31
30
from tesla_fleet_api import TeslaBluetooth
32
31
33
32
asyncdefmain():
34
-
scanner = BleakScanner()
35
-
devices =await scanner.discover()
36
-
for device in devices:
37
-
if TeslaBluetooth().valid_name(device.name):
38
-
print(f"Found Tesla vehicle: {device.name}")
39
-
name =await TeslaBluetooth().query_display_name(device)
print(f"Woke up VehicleBluetooth instance for VIN: {vehicle.vin}")
76
+
77
+
asyncio.run(main())
78
+
```
79
+
80
+
## Get Vehicle Data
81
+
82
+
You can get data from a `VehicleBluetooth` instance using the `vehicle_data` method. Here's a basic example to get data from a `VehicleBluetooth` instance:
70
83
71
84
```python
72
85
import asyncio
73
-
from bleak import BleakScanner
74
86
from tesla_fleet_api import TeslaBluetooth, BluetoothVehicleData
0 commit comments