Skip to main content

Asynchronous Python client for the Teslamate API

Project description

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())

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.

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

pyteslamate-0.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyteslamate-0.1.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pyteslamate-0.1.1.tar.gz.

File metadata

  • Download URL: pyteslamate-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for pyteslamate-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9cedb655bc841c8add6913d60f9ee8988b255a8c9f1f470609444a4ba232a169
MD5 4c429b859227e14e1bd117e7ca1b3205
BLAKE2b-256 8c61e13cc320d128c7de4829d21241ca77437b10675e04d57d834fcc1e2bb789

See more details on using hashes here.

File details

Details for the file pyteslamate-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyteslamate-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for pyteslamate-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 111c8650e5f99d5ae2469695c0f13f1c1a1df0af15e7a6dfd3913af83fb8bb4a
MD5 4ef3e13da783b005952caba41305f399
BLAKE2b-256 f111bcdb0f6faaa41513c5d2e716253c5d517f4e363785b22a92e09b3201f9a6

See more details on using hashes here.

Supported by

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