Skip to main content

Teslemetry Streaming API library for Python

Project description

Teslemetry Stream Library

This is an asynchronous Python 3 library that connects to the Teslemetry Stream server and provides Tesla Fleet Telemetry using server side events.

Installation

pip install teslemetry-stream

Usage

The TeslemetryStream class requires:

  • session: an aiohttp.ClientSession
  • access_token: an access token from the Teslemetry console
  • One or both:
    • vin: your Tesla's Vehicle Identification Number
    • server: The Teslemetry server to connect to

The full list of possible values are provided in TeslemetryStream.Fields and TeslemetryStream.Alerts

To connect, either use async with on the instance, call connect(), or register an callback with async_add_listener, which will connect when added and disconnect when removed.

Using connect() or listen() will require you to close the session manually using close().

Example

The following example puts the listening loop in the background, then stopping after 20 seconds.

async def main():
    async with aiohttp.ClientSession() as session:
        stream = TeslemetryStream(
            access_token="<token>",
            vin="<vin>",
            session=session,
        )
        await stream.connect()

        def callback(event):
            print(event["data"])

        remove = stream.async_add_listener(callback)

        print("Running")
        await asyncio.sleep(60)
        remove()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

teslemetry_stream-0.4.2.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

teslemetry_stream-0.4.2-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file teslemetry_stream-0.4.2.tar.gz.

File metadata

  • Download URL: teslemetry_stream-0.4.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for teslemetry_stream-0.4.2.tar.gz
Algorithm Hash digest
SHA256 f350da306f9637e45eaf1ab398738b4d4e1bf6e14c5467418d0341eb40857b20
MD5 c29e51a027836bed90bc583a40c26aad
BLAKE2b-256 897a4865361f96b4c61a1d43670e6175b93aa3c7df009f97e99084a5494e8058

See more details on using hashes here.

File details

Details for the file teslemetry_stream-0.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for teslemetry_stream-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c521da257b655c42e974e99eb9846cc5d826c8150015cea602e40ffe75b8f36b
MD5 753fb3aaee0dceb17aa104373955a2bb
BLAKE2b-256 2ac59aba02aad173e8569b33a1929f3c3e0ac1cc63c5776074d0238c5bcb98f2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page