Skip to main content

Async Tesla Powerwall 3 client over the TEDAPI v1r RSA-signed LAN protocol.

Project description

aiopowerwall

An async Tesla Powerwall 3 client built on aiohttp, written for Home Assistant and any other asyncio code.

Status

Beta (0.x). The wire protocol and the public Python API may change between minor versions until 1.0. Pin a tight version range if you depend on this library in production.

This library speaks the Powerwall's TEDAPI v1r protocol — RSA-signed protobuf messages directly to your Powerwall. It is intentionally scoped to:

  • Powerwall 3, and updated Powerwall 2 (untested)
  • Local LAN access only (no cloud telemetry)
  • Read + control commands (status, config, firmware, components, max-backup)

The RSA key pair used for v1r authentication must be registered with the gateway out-of-band, typically via the Tesla Fleet API. This library consumes an already-paired private key — it does not implement registration.

Install

pip install aiopowerwall

Quick start

import asyncio
from pathlib import Path
from aiopowerwall import PowerwallClient, current_power

async def main() -> None:
    pem = Path("tedapi_rsa_private.pem").read_bytes()
    async with PowerwallClient(
        host="192.168.91.1",
        gateway_password="<gateway-password>",
        rsa_private_key_pem=pem,
    ) as pw:
        await pw.connect()
        print("DIN:", pw.din)
        print("Battery SoC:", await pw.get_battery_soe(), "%")
        print("Grid:", await pw.get_grid_status())
        status = await pw.get_status()
        print("Power:", current_power(status))

asyncio.run(main())

API surface

Every method issues a fresh request — the library does not cache responses. If you need a value derived from a payload, fetch the payload once and pass it to the pure helper functions.

Method Returns
connect() DIN string
get_din() DIN string
get_config() config.json (dict)
get_status() DeviceController query (narrow)
get_device_controller() DeviceController query (extended)
get_components() Powerwall 3 component data
get_firmware_details() Firmware details dict
get_meters_aggregates() /api/meters/aggregates
get_battery_soe() Battery SoC percentage
get_grid_status() Grid status string
write_config(updates) Patch config.json (dotted paths)
schedule_max_backup(seconds) Schedule manual backup event
cancel_max_backup() Cancel manual backup event
get_backup_events() Active and scheduled backup events

Pure helpers (operate on an already-fetched status payload):

Function Returns
battery_level(status) SoC percentage computed from status
current_power(status) {location: realPowerW} map
backup_time_remaining(status) Hours of backup at current load

Exceptions

All errors are subclasses of PowerwallError:

  • PowerwallConnectionError — transport failure / timeout
  • PowerwallAuthenticationError — bad password or unregistered RSA key
  • PowerwallRateLimitError — gateway returned 429/503
  • PowerwallFaultError — signed-message fault (key inactive, expired, etc.)
  • PowerwallProtocolError — malformed response

Acknowledgements

This project builds on the protocol research and reference implementation in pypowerwall by Jason Cox, distributed under the MIT License. Huge thanks to Jason and the pypowerwall contributors for reverse-engineering and documenting the TEDAPI protocol.

License

MIT (see LICENSE). Original pypowerwall copyright and license notice are retained in 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

aiopowerwall-0.1.1.tar.gz (30.5 kB view details)

Uploaded Source

Built Distribution

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

aiopowerwall-0.1.1-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiopowerwall-0.1.1.tar.gz
  • Upload date:
  • Size: 30.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aiopowerwall-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ba872fb1f40eb58d67934172c8a1b0b8f1fbff916e54f6e466aa0cf532c07729
MD5 714e9eb2431d0b1dcf9ef2ef0bf5c19b
BLAKE2b-256 cbbd088b69116e96426b725e047b35f49c301f86f97446ccf27196ff4ae3855e

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiopowerwall-0.1.1.tar.gz:

Publisher: pypi-publish.yml on Teslemetry/aiopowerwall

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: aiopowerwall-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 35.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aiopowerwall-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 935b4c09a244b6fb2c35c0487430f9a148a1706a509e82efeb60760920a70045
MD5 d358c221de998d5d07b50ae7cf9aac27
BLAKE2b-256 b86c25a921b79525f7f0572fa249e9de5e4b57a8394c65bb19333e4f86b811c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiopowerwall-0.1.1-py3-none-any.whl:

Publisher: pypi-publish.yml on Teslemetry/aiopowerwall

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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