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
Copy file name to clipboardExpand all lines: README.md
+74-5Lines changed: 74 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,11 @@
1
1
# Teslemetry Stream Library
2
-
This is an asynchronous Python 3 library that connects to the Teslemetry Stream server and provides Tesla Fleet Telemetry using server side events.
2
+
This is an asynchronous Python 3 library that connects to the Teslemetry Stream service and provides Tesla Fleet Telemetry using server sent events. The library allows you to listen to various telemetry signals from Tesla vehicles, and provides a convenient way to handle these signals using typed listen methods.
3
+
4
+
## Capabilities
5
+
- Connect to the Teslemetry Stream service
6
+
- Listen to various telemetry signals from Tesla vehicles
7
+
- Handle signals using typed listen methods
8
+
- Write custom listeners for multiple signals
3
9
4
10
## Installation
5
11
@@ -25,6 +31,61 @@ Using `connect()` or `listen()` will require you to close the session manually u
25
31
## Example
26
32
The following example puts the listening loop in the background, then stopping after 20 seconds.
27
33
```
34
+
async def main():
35
+
async with aiohttp.ClientSession() as session:
36
+
async with TeslemetryStream(
37
+
access_token="<token>",
38
+
vin="<vin>", # for single vehicles
39
+
server="na.teslemetry.com" # or "eu.teslemetry.com"
40
+
session=session,
41
+
) as stream:
42
+
43
+
def callback(event):
44
+
print(event["data"])
45
+
46
+
remove = stream.async_add_listener(callback)
47
+
48
+
print("Running")
49
+
await asyncio.sleep(60)
50
+
remove()
51
+
```
52
+
53
+
## Using Typed Listen Methods
54
+
55
+
The library provides typed listen methods for various telemetry signals. These methods allow you to listen to specific signals and handle their data in a type-safe manner. Here is an example of using the typed listen methods:
56
+
57
+
```python
58
+
asyncdefmain():
59
+
asyncwith aiohttp.ClientSession() as session:
60
+
asyncwith TeslemetryStream(
61
+
access_token="<token>",
62
+
vin="<vin>", # for single vehicles
63
+
server="na.teslemetry.com"# or "eu.teslemetry.com"
0 commit comments