Skip to main content

GitHub Actions Workflow Status PyPI - Version PyPI - Python Version TeslaMateApi Compatibility PyPI - License

pyTeslaMate

pyTeslaMate is an asynchronous Python client for the TeslaMateApi. Provides asyncio-friendly helpers to fetch cars, drives, charges, status and global settings using aiohttp and Pydantic v2 models.

TeslaMateApi is a RESTful API written in Go to get data of the awesome self-hosted data logger TeslaMate.

In order to use pyTeslaMate you need to have fully working:

  1. TeslaMate
  2. TeslaMateApi

Installation

pyTeslaMate installation:

pip install pyteslamate

Install the project and development tools (requires uv):

uv sync --all-extras --dev

Or install from source:

uv build
uv run pip install dist/*.whl

Quickstart

Create an async client and call the API:

import asyncio
from datetime import datetime
from pyteslamate import Teslamate

async def main():
    async with Teslamate(base_url="https://api.example.com/api/v1/") as client:
    # fetch all cars
    cars = await client.get_cars()
    print(cars.model_dump())
    # fetch charges for car 1 in a date range
    charges = await client.get_car_charges(
        1,
        start_date=datetime(2025, 12, 1),
        end_date=datetime(2025, 12, 8),
    )
    print(charges.model_dump())
    # drives starting or ending at a location (teslamateapi >= 1.25.0);
    # get_car_charges accepts location too
    drives = await client.get_car_drives(1, location="home")
    print(drives.model_dump())

if __name__ == "__main__":
    asyncio.run(main())

Models

All response payloads are validated into Pydantic v2 models under pyteslamate.models. Use:

  • .model_validate(data) to validate a dict
  • .model_dump() / .model_dump_json() to serialize

Current Limitations & Future Work

Command Operations

Currently, only read operations are implemented. Write operations for sending commands to vehicles (e.g., wake up, climate control, charging control) are planned for future releases.

API Key Authentication

API key authentication is not yet tested or fully supported. Implementation is pending the merge of a PR in TeslaMateApi that will enable API key functionality. Once merged, authentication support will be added with comprehensive test coverage.

Testing & Coverage

Run the tests and show missing coverage:

uv run pytest --cov=src --cov-report=term-missing --cov-report=html

Open generated HTML report:

xdg-open htmlcov/index.html

Development

Run linters / formatters and pre-commit:

pre-commit run --all-files

Key checks included: ruff, mypy, pylint, pytest, yamllint, codespell.

Contributing

  • Follow existing style (pylint / ruff)
  • Add tests for new features (use tests/response_examples.py fixtures)
  • Keep Pydantic models in src/pyteslamate/models.py synchronized with API payloads

License

This project is licensed under the MIT License.

Metadata

Release files for pyteslamate 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyteslamate 0.2.0
File Size Uploaded
pyteslamate-0.2.0.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyteslamate 0.2.0
File Interpreter ABI Platform
pyteslamate-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.6 kB

Release files / pyteslamate-0.2.0.tar.gz

Download URL pyteslamate-0.2.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6a2d9ed6bdeba77b6c50f6a71cb1c62d486a5e051d1dcb2bf80d4d5df8f6137c
BLAKE2b-256 checksum
How to use checksums
75b6fda888896137710fb9e81c0848a9941f2d3c56b99aab02347f965db699b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pyteslamate-0.2.0-py3-none-any.whl

Download URL pyteslamate-0.2.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
adc6098e27a245819036743ef10d5b6b9c34f7626800b207cbe3e39aa92a764b
BLAKE2b-256 checksum
How to use checksums
2601ed3efbdbbbbcdca869a816bdface9a5643661d6e99caea7f26b69171156e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page