SkillAgentSearch skills...

Pypowerwall

Python API for Tesla Powerwall and Solar Power Data

Install / Use

/learn @jasonacox/Pypowerwall

README

pyPowerwall

License PyPI version CI simtest Python Version PyPI Downloads

pyPowerwall is a Python module to interface with Tesla Energy Gateways for Powerwall and solar power data. It supports local access to Powerwall, Powerwall 2, Powerwall+ and Powerwall 3 systems. It also provides Tesla Owner and FleetAPI cloud access for all systems including Solar-only systems. For Powerwall 3 on wired LAN, the v1r TEDAPI mode provides full local access using RSA-signed protobuf messages without needing Wi-Fi access.

⚠️ NOTICE: As of Powerwall Firmware version 25.10.0, network routing to the TEDAPI endpoint (192.168.91.1) is no longer supported by Tesla. You must connect directly to the Powerwall's Wi‑Fi access point to access TEDAPI data.

Description

This Python module can be used to monitor and control Tesla Energy Powerwalls. It uses a single class (Powerwall) and simple functions to fetch energy data and poll API endpoints on the Gateway.

pyPowerwall will cache the authentication headers and API call responses to help reduce the number of calls made to the Gateway (useful if you are polling the Powerwall frequently for trending data).

  • Works with Tesla Energy Gateways - Powerwall, Powerwall+ and Powerwall 3
  • Access provided via Local Gateway APIs, Tesla FleetAPI (official), Tesla Owners API (unofficial), and v1r LAN TEDAPI (Powerwall 3).
  • Will cache authentication to reduce load on Powerwall Gateway
  • Will cache responses to limit the number of calls to the Powerwall Gateway or cloud (optional/user‑definable)
  • Will re-use HTTP connections to the Powerwall Gateway for reduced load and faster response times
  • Provides solar string data for Powerwall+ and Powerwall 3 systems.

Setup

You can clone this repo or install the package with pip. Once installed, pyPowerwall can scan your local network to find the IP address of your Tesla Powerwall Gateway.

# Install pyPowerwall
python3 -m pip install pypowerwall

# Option 1 - LOCAL MODE - Scan Network for Powerwalls
python3 -m pypowerwall scan

# Option 2 - FLEETAPI CLOUD MODE - Setup to use the official Tesla FleetAPI - See notes below.
python3 -m pypowerwall fleetapi

# Option 3 - CLOUD MODE - Setup to use Tesla Owners cloud API
python3 -m pypowerwall setup

# Option 4 - TEDAPI MODE - Test this mode (requires extended setup - see below)
python3 -m pypowerwall tedapi

# Option 5 - v1r LAN TEDAPI MODE - Powerwall 3 wired LAN access (see below)

Local Setup - Option 1

The Tesla Powerwall, Powerwall 2 and Powerwall+ have a local LAN based Web Portal and API that you can use to monitor your Powerwall. It requires that you (or your installer) have the IP address (see scan above) and set up Customer Login credentials on your Powerwall Gateway. That is all that is needed to connect.

The Powerwall 3 does not have a traditional Web Portal or API but you can access it via the cloud (see options 2 and 3), via the TEDAPI Wi-Fi access point (option 4), or via the wired LAN using v1r TEDAPI (option 5).

Locally accessible extended device vitals metrics are available using the TEDAPI method (see options 4 and 5 below).

FleetAPI Cloud Setup - Option 2

FleetAPI is the official Tesla API for accessing your Tesla products. This setup has some additional setup requirements that you will be prompted to do:

Step 1 - Tesla Partner Account - Sign in to Tesla Developer Portal and make an App Access Request: See Tesla App Access Request - During this process, you will need to set up and remember the following account settings:

  • CLIENT_ID - This will be provided to you by Tesla when your request is approved.
  • CLIENT_SECRET - Same as above.
  • DOMAIN - The domain name of a website you own and control.
  • REDIRECT_URI - This is the URL that Tesla will direct you to after you authenticate. This landing URL (on your website) will extract the GET variable code, which is a one-time use authorization code needed during the pyPowerwall setup. You can use https://pypowerwall.com/code or copy the code from index.html to your site and update REDIRECT_URI with that URL. Alternatively, you can just copy the URL from the 404 page during the authorization process (the code is in the URL).

Step 2 - Run the create_pem_key.py script and place the public key on your website at the URL: https://{DOMAIN}/.well-known/appspecific/com.tesla.3p.public-key.pem

Step 3 - Run python3 -m pypowerwall fleetapi - The credentials and tokens will be stored in the .pypowerwall.fleetapi file.

Cloud Mode - Option 3

The unofficial Tesla Owners API allows FleetAPI access (option 2) without having to set up a website and PEM key. Follow the directions given to you by running python3 -m pypowerwall setup. The credentials and site_id will be stored in .pypowerwall.auth and .pypowerwall.site.

TEDAPI Mode - Option 4

With version v0.10.0+, pypowerwall can access the TEDAPI endpoint on the Gateway over Wi-Fi. This API offers additional metrics related to string data, voltages, and alerts. You will need the Gateway Wi‑Fi password (found on the QR sticker on the Powerwall Gateway) and network access to 192.168.91.1 (either via the Gateway’s Wi‑Fi AP or a static route from your LAN).

Full vs Hybrid TEDAPI

Option 4 operates in two sub-modes depending on which credentials you provide:

  • Full TEDAPI — Set only gw_pwd (leave password empty). Uses the full Gateway Wi‑Fi password for HTTP Basic Auth directly to the TEDAPI protobuf endpoint. Works on PW2/+/3.
  • Hybrid TEDAPI — Set both password (last 5 chars) and gw_pwd. The customer password authenticates via /api/login/Basic for standard JSON API access, while gw_pwd enables TEDAPI for supplemental vitals data (string voltages, per‑device alerts, etc.). Useful on PW2/+ where the customer API provides data that TEDAPI does not.

Network Requirements (Wi-Fi)

Your machine must be able to reach 192.168.91.1. Options:

  • Connect directly to the Gateway’s Wi‑Fi access point
  • Add a static route from your LAN through the Gateway’s home-network IP (see examples below)

Note: Some firmware versions (25.10.0+) may block routed access to 192.168.91.1. In that case, connect directly to the Gateway Wi‑Fi.

⚠️ TEDAPI Limitations: Some functions are only available via FleetAPI or Cloud mode. Known limitations include get_grid_charging() and get_grid_export(), which rely on Fleet API endpoints not exposed locally — these return None in TEDAPI mode with a log warning. Use FleetAPI (Option 2) or Cloud mode (Option 3) for full functionality.

In the examples below, change 192.168.0.100 to the IP address of the Powerwall Gateway (or Inverter) on your LAN. Also, the onlink parameter may be necessary for Linux.

Linux Ubuntu and RPi

# Can add to /etc/rc.local for persistence
sudo ip route add 192.168.91.1 via 192.168.0.100 [onlink]

See examples/network_route.py for two different approaches to do this programmatically in Python.

macOS

sudo route add -host 192.168.91.1 192.168.0.100 # Temporary 
networksetup -setadditionalroutes Wi-Fi 192.168.91.1 255.255.255.255 192.168.0.100 # Persistent

Windows - Using the persistence flag - Administrator Shell

route -p add 192.168.91.1 mask 255.255.255.255 192.168.0.100

Windows Subsystem for Linux (WSL 2–specific)

Follow the instructions for Linux, but you must edit (from the host Windows OS) %USERPROFILE%\.wslconfig and add the following settings:

[wsl2]
networkingMode=mirrored
# Test
python3 -m pypowerwall tedapi

TEDAPI Troubleshooting

  • Connection refused/timeout: Ensure you’re connected to the Powerwall’s Wi‑Fi or have a working route to 192.168.91.1. Some firmware versions (25.10.0+) block routing; connect directly to the PW Wi‑Fi.
  • Auth failures: Use the Gateway Wi‑Fi password from the QR label as gw_pwd (case‑sensitive). Customer portal passwords do not work for TEDAPI.
  • TLS/certificate warnings: TEDAPI uses a self‑signed cert; most tools need --insecure (curl) or verify=False (requests). Use only on trusted networks.
  • Hybrid mode quirks (PW2/+): If both customer password/email and gw_pwd are provided, TEDAPI data augments local APIs; try removing customer creds if you only need TEDAPI.
  • QNAP/Appliance routing: Static routes from shell may be ignored; use the appliance’s network control panel to add a persistent host route.

v1r LAN TEDapi Setup - Option 5 (Powerwall 3 Wired LAN)

The Powerwall 3 exposes endpoints on the wired LAN (the vendor/third-party Ethernet port) that provide local access to Powerwall data without needing Wi-Fi access to 192.168.91.1. This is especially useful for always-on monitoring setups where a wired Ethernet connection to the Powerwall gateway is available.

Option 5 has two sub-modes:

  • Basic LAN — Uses /api/login/Basic for a Bearer token + standard JSON API endpoints. No FleetAPI setup or RSA keys needed. Provides core power/battery/grid data (3 endpoints).
  • Full v1r — Uses RSA-4096 signed protobuf messages to the /tedapi/v1r endpoint
View on GitHub
GitHub Stars200
CategoryDevelopment
Updated1d ago
Forks50

Languages

JavaScript

Security Score

100/100

Audited on Mar 30, 2026

No findings