### Setup and Run Development Server Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/server/README.md Commands to set up the development environment, install dependencies, and run the server with auto-reloading. ```bash # Navigate to server directory cd tools/server # Create virtual environment python -m venv venv source venv/bin/activate # or `venv\Scripts\activate` on Windows # Install dependencies pip install -e ".[dev]" # Run development server with auto-reload uvicorn app.main:app --reload --port 8080 ``` -------------------------------- ### Install and Scan for Powerwall Gateways Source: https://context7.com/jasonacox/pypowerwall/llms.txt Install the pyPowerwall library and scan the local network for Powerwall gateways. The setup command can also be used to configure access to Tesla Cloud or FleetAPI. ```bash python3 -m pip install pypowerwall ``` ```bash # Scan local network for Powerwall gateways python3 -m pypowerwall scan # Example output: # Host: 10.0.1.36 ... Found Powerwall 1232100-00-E--TG123456789ABG ``` ```bash # Setup Tesla Cloud (Owners API) python3 -m pypowerwall setup ``` ```bash # Setup Tesla FleetAPI (official, requires developer account) python3 -m pypowerwall setup -fleetapi ``` ```bash # Test TEDAPI Wi-Fi connection python3 -m pypowerwall tedapi -gw_pwd ABCDEXXXXX ``` ```bash # Register RSA key for Powerwall 3 wired LAN (v1r) access python3 -m pypowerwall setup -v1r ``` -------------------------------- ### Installation and Setup Commands Source: https://context7.com/jasonacox/pypowerwall/llms.txt Commands for installing pyPowerwall and setting up different access modes for your Powerwall system. ```APIDOC ## Installation ```bash python3 -m pip install pypowerwall ``` ## Scanning for Gateways ```bash python3 -m pypowerwall scan ``` ## Setup ### Tesla Cloud (Owners API) ```bash python3 -m pypowerwall setup ``` ### Tesla FleetAPI ```bash python3 -m pypowerwall setup -fleetapi ``` ### TEDAPI Wi-Fi Connection Test ```bash python3 -m pypowerwall tedapi -gw_pwd ABCDEXXXXX ``` ### Powerwall 3 Wired LAN (v1r) RSA Key Registration ```bash python3 -m pypowerwall setup -v1r ``` ``` -------------------------------- ### Install and Run pypowerwall CLI Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Install the pypowerwall library and run basic commands for scanning the network or setting up API access. ```bash python -m pip install pypowerwall ``` ```bash python -m pypowerwall scan ``` ```bash python -m pypowerwall setup -fleetapi ``` ```bash python -m pypowerwall setup ``` ```bash python -m pypowerwall tedapi -gw_pwd ABCDEXXXXX ``` ```bash python -m pypowerwall setup -v1r ``` -------------------------------- ### Cloud Mode Setup with Email Argument Source: https://github.com/jasonacox/pypowerwall/blob/main/RELEASE.md Streamline the Powerwall-Dashboard setup script by providing an optional email address during Cloud Mode setup using the `-email=` argument. ```bash python -m pypowerwall setup -email= ``` -------------------------------- ### Install and Run pyPowerwall Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Install the pyPowerwall package using pip and run various command-line interface options for setup and scanning. ```bash python3 -m pip install pypowerwall ``` ```bash python3 -m pypowerwall scan ``` ```bash python3 -m pypowerwall setup -fleetapi ``` ```bash python3 -m pypowerwall setup ``` ```bash python3 -m pypowerwall tedapi ``` ```bash python3 -m pypowerwall setup -v1r ``` -------------------------------- ### Example Output of pypowerwall get Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md This is an example of the text output format when retrieving Powerwall status, showing site information, firmware, battery level, and grid status. ```text pyPowerwall [0.15.6] - Get Powerwall settings using Local (v1r+wifi+control) mode. Site Cox Power Plant Site ID N/A DIN 1707000-11-M--TG1234567890TB Firmware 25.10.0 Mode self_consumption Reserve 20.0 Battery Level 64.2 Grid Status UP Grid 12 Home 5588.5 Battery 1613 Solar 3965 Grid Charging True Grid Export Mode pv_only Time Remaining N/A ``` -------------------------------- ### FleetAPI Setup using pypowerwall module Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/fleetapi/README.md Initiates the FleetAPI setup process using the pypowerwall module. Configuration data will be stored in the .pypowerwall.fleetap file. ```bash python -m pypowerwall fleetapi ``` -------------------------------- ### Run Performance Test - Full Example Source: https://github.com/jasonacox/pypowerwall/blob/main/proxy/README.md A comprehensive example demonstrating the use of all available options for the performance testing script, including custom host, port, request count, and timeout. ```bash # Full example with all options python perf_test.py --host myproxy.local --port 9999 --requests 3 --timeout 15 ``` -------------------------------- ### Install Protobuf Source: https://github.com/jasonacox/pypowerwall/blob/main/examples/vitals/README.md Install the protobuf Python module using pip. This is required for handling the Powerwall API's binary payload. ```bash pip install protobuf ``` -------------------------------- ### Install and Run PyPowerwall Server from Command Line Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/server/README.md Install the server using pip and run it directly from the command line. Supports both single and multiple Powerwall configurations. ```bash # Install pip install pypowerwall-server # Single Powerwall pypowerwall-server --host 192.168.91.1 --gw-pwd your_gateway_password # Multiple Powerwalls pypowerwall-server --config gateways.yaml ``` -------------------------------- ### Powerwall Config Request Example Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/tedapi/README.md This example demonstrates how to request configuration data from the Powerwall. It includes steps to create the request file, send the request using curl, and decode the binary response. ```bash # First you will need a request.bin - Create example: python create_request.py # Request Config Data from Powerwall curl -v -k -H 'Content-type: application/octet-string' -u "Tesla_Energy_Device:GW_PWD" --data-binary @request.bin https://192.168.91.1/tedapi/v1 > response.bin # Decode Config Data python3 decode.py response.bin ``` -------------------------------- ### Install Python Modules and Login for Set Reserve Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/README.md Installs necessary Python modules and initiates the login process to set up authentication tokens for the `set-reserve.py` tool. This creates a configuration file and saves an auth token for future use. ```bash # Install python modules pip install python-dateutil pypowerwall # Login to Tesla account to set up token python3 set-reserve.py --login ``` ```text Config file 'set-reserve.conf' not found Do you want to create the config now? [Y/n] Y Tesla Account Setup ------------------- Email address: your@email.address Save auth token to: [set-reserve.auth] Config saved to 'set-reserve.conf' ``` ```text ---------------------------------------- Tesla account: your@email.address ---------------------------------------- Open the below address in your browser to login. e.g.: https://auth.tesla.com/oauth2/v3/authorize?response_type=code...etc. After login, paste the URL of the 'Page Not Found' webpage below. Enter URL after login: e.g.: https://auth.tesla.com/void/callback?code=...etc. ``` ```text ---------------------------------------- Tesla account: your@email.address ---------------------------------------- Site ID: 1234567890 Site name: My Powerwall Timezone: Australia/Sydney Installed: 2021-04-01 13:09:54+11:00 System time: 2022-10-13 22:40:59+11:00 ---------------------------------------- ``` -------------------------------- ### Run Docker Container Source: https://github.com/jasonacox/pypowerwall/blob/main/pwsimulator/README.md Starts the pyPowerwall simulator Docker container, mapping port 443 for HTTPS access. Ensure Docker is installed and running. ```bash docker run \ -d \ -p 443:443 \ --name pwsimulator \ --restart unless-stopped \ jasonacox/pwsimulator ``` -------------------------------- ### PyPowerwall Command Line Interface Usage Source: https://github.com/jasonacox/pypowerwall/blob/main/RELEASE.md Displays the usage instructions for the PyPowerwall command-line interface, outlining available commands such as setup, scan, set, get, and version. ```bash usage: PyPowerwall [-h] {setup,scan,set,get,version} ... PyPowerwall Module v0.8.1 options: -h, --help show this help message and exit commands (run -h to see usage information): {setup,scan,set,get,version} setup Setup Tesla Login for Cloud Mode access scan Scan local network for Powerwall gateway set Set Powerwall Mode and Reserve Level get Get Powerwall Settings and Power Levels version Print version information ``` -------------------------------- ### Run FleetAPI Setup Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Execute this command to set up FleetAPI. Credentials and tokens will be stored in the .pypowerwall.fleetapi file. ```bash python3 -m pypowerwall fleetapi ``` -------------------------------- ### Setup Cloud Mode and Fetch Tesla Owners API Token Source: https://github.com/jasonacox/pypowerwall/blob/main/RELEASE.md Run this command to initiate the cloud mode setup process, which includes fetching your Tesla Owners API Token. The token and site information will be stored in `.pypowerwall.auth` and `.pypowerwall.site` files. ```bash python3 -m pypowerwall setup # Token and site information stored in .pypowerwall.auth and .pypowerwall.site ``` -------------------------------- ### Powerwall Query Request Example Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/tedapi/README.md This example shows how to request status data from the Powerwall. It involves sending a binary `query.bin` payload and decoding the response. ```bash # Request Status Data from Powerwall curl -v -k -H 'Content-type: application/octet-string' -u "Tesla_Energy_Device:GW_PWD" --data-binary @query.bin https://192.168.91.1/tedapi/v1 > response.bin # Decode Config Data python3 decode.py response.bin ``` -------------------------------- ### Install Runtime Dependencies Source: https://github.com/jasonacox/pypowerwall/blob/main/CONTRIBUTING.md Install the necessary Python packages required to run the PyPowerwall package. This is done using pip and the requirements.txt file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install Dependencies and Run Original TEDAPI Script Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/tedapi/README.md Clone the pypowerwall repository, navigate to the tedapi directory, install dependencies, and run the tedapi_orig.py script to fetch and save configuration and status. ```bash # Download git clone https://github.com/jasonacox/pypowerwall.git cd pypowerwall/tools/tedapi # Install required dependencies pip install protobuf requests # Get configuration and status python tedapi_orig.py ``` -------------------------------- ### Install Python Modules and Login for Set Mode Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/README.md Installs necessary Python modules and initiates the login process to set up authentication tokens for the `set-mode.py` tool. This process is similar to the 'Set Reserve' tool. ```bash # Install python modules pip install python-dateutil pypowerwall # Login to Tesla account to set up token python3 set-mode.py --login ``` -------------------------------- ### Obtain Authentication Token Locally Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md On a machine with a display, run this command to get an authentication token. This token is then used in remote sessions for setup. ```bash # On your local machine (Mac/Windows/Linux with a display): python3 -m pypowerwall authtoken # Follow the Tesla login flow in the popup window. # Copy the token printed to the terminal. # Then on the remote machine, run setup and paste the token when prompted: python3 -m pypowerwall setup ``` -------------------------------- ### Install pyPowerwall on FreeBSD via ports Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Install the pyPowerwall package on FreeBSD systems by compiling from ports. ```bash # cd /usr/ports/net-mgmt/py-pypowerwall/ && make install clean ``` -------------------------------- ### Install and Run TEDAPI Command-Line Tool Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/tedapi/README.md Install the pypowerwall package and run the TEDAPI tool from the command line. It prompts for the gateway password and saves configuration and status to JSON files. ```bash # First, install or upgrade if you haven't pip install -U pypowerwall # Run the tool python3 -m pypowerwall.tedapi ``` ```text Tesla Powerwall Gateway TEDAPI Reader Enter Powerwall Gateway Password: ********** Connecting to Powerwall Gateway 192.168.91.1 - Configuration: - Site Name: Energy Gateway - Battery Commission Date: 2022-09-25T12:01:00-07:00 - VIN: 1232100-00-E--TG123456789012 - Number of Powerwalls: 2 - Power Data: - Battery Charge: 100.0% (25772Wh of 25772Wh) - Battery: -10W - Site: -337W - Load: 1108W - Solar: 1460W - Solar_Rgm: 1447W - Generator: 0W - Conductor: 0W - Configuration and Status saved to config.json and status.json ``` -------------------------------- ### Python Powerwall Control Example Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Interact with the Powerwall using the pypowerwall library. This example demonstrates reading and setting various parameters like reserve, mode, and grid charging. Note that setting backup reserve above 80% is only supported in v1r LAN mode. ```python import pypowerwall pw = pypowerwall.Powerwall( host="10.42.1.40", gw_pwd="ABCDEXXXXX", rsa_key_path="/path/to/tedapi_rsa_private.pem" ) # Read current settings print(pw.get_mode()) # "self_consumption" print(pw.get_reserve()) # 20 print(pw.get_grid_charging()) # False print(pw.get_grid_export()) # "pv_only" # Set new values pw.set_reserve(30) pw.set_mode("backup") pw.set_grid_charging(True) pw.set_grid_export("battery_ok") # Max backup (v1r only) - sets reserve to 100% for duration pw.schedule_max_backup(3600) # 1 hour pw.cancel_max_backup() print(pw.get_backup_events()) # {"manual_backup": {...}, "backup_events": [...]} ``` -------------------------------- ### Install pyPowerwall on FreeBSD via pkg Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Install the pyPowerwall package on FreeBSD systems using the pkg package manager. ```bash # pkg install net-mgmt/py-pypowerwall ``` -------------------------------- ### Install PyPowerwall Dependencies Source: https://github.com/jasonacox/pypowerwall/blob/main/API.md Install the necessary Python packages for PyPowerwall using pip. Ensure you have requests and protobuf installed. ```sh pip install requests protobuf ``` -------------------------------- ### Install and Scan for Powerwall Source: https://github.com/jasonacox/pypowerwall/blob/main/docs/README.md Install the pyPowerwall library and scan your network to discover your Powerwall gateway's IP address. This is a prerequisite for accessing the local Powerwall portal. ```bash python -m pip install pypowerwall ``` ```bash python -m pypowerwall scan ``` -------------------------------- ### Install PyPowerwall and Authorize TeslaPy Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/README.md Install the necessary Python modules using pip and then run the tessolarcharge.py script to initiate the TeslaPy authorization process. Follow the on-screen prompts to log in via your Tesla account and paste the callback URL. ```bash # Install python modules pip install pypowerwall # Login to Tesla account to set up token python3 tessolarcharge.py ``` -------------------------------- ### FleetAPI Setup Command Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/fleetapi/README.md Sets up the FleetAPI for your site. This command is part of the standalone FleetAPI tool. ```bash python fleetapi.py setup ``` -------------------------------- ### Example Usage Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/fleetapi/README.md Demonstrates how to import and use the FleetAPI class in Python scripts for monitoring and control. ```APIDOC ```python from fleetapi import FleetAPI fleet = FleetAPI() # Current Status print(f"Solar: {fleet.solar_power()}") print(f"Grid: {fleet.grid_power()}") print(f"Load: {fleet.load_power()}") print(f"Battery: {fleet.battery_power()}") print(f"Battery Level: {fleet.battery_level()}") # Change Reserve to 30% fleet.set_battery_reserve(30) # Change Operating Mode to Autonomous fleet.set_operating_mode("autonomous") ``` ``` -------------------------------- ### Launch Docker Compose Stack Source: https://github.com/jasonacox/pypowerwall/wiki/Powerwall-Dashboard Start the stack of Docker containers for the Powerwall monitoring system. ```bash docker-compose -f powerwall.yml up -d ``` -------------------------------- ### Get and Set Grid Control Modes Source: https://github.com/jasonacox/pypowerwall/blob/main/RELEASE.md Manage grid charging and exporting modes using the `pypowerwall` command-line interface or programming examples. Supports FleetAPI and Cloud modes only. Use `setup` to configure connection details. ```bash # Connect to Cloud python3 -m pypowerwall setup # or fleetapi # Get Current Settings python3 -m pypowerwall get # Turn on Grid charging python3 -m pypowerwall set -gridcharging on # Turn off Grid charging python3 -m pypowerwall set -gridcharging off # Set Grid Export to Solar (PV) energy only python3 -m pypowerwall set -gridexport pv_only # Set Grid Export to Battery and Solar energy python3 -m pypowerwall set -gridexport battery_ok # Disable export of all energy to grid python3 -m pypowerwall set -gridexport never ``` ```python import pypowerwall # FleetAPI Mode PW_HOST="" PW_EMAIL="my@example.com" pw = pypowerwall.Powerwall(host=PW_HOST, email=PW_EMAIL, fleetapi=True) # Get modes pw.get_grid_charging() pw.get_grid_export() # Set modes pw.set_grid_charging("on") # set grid charging mode (on or off) pw.set_grid_export("pv_only") # set grid export mode (battery_ok, pv_only, or never) ``` -------------------------------- ### Get Site Name Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Retrieves the name of the Powerwall installation site. ```python site_name() ``` -------------------------------- ### Initialize Powerwall Instance (Basic) Source: https://github.com/jasonacox/pypowerwall/blob/main/API.md Create an instance of the Powerwall class by providing the gateway's IP address, password, and your Tesla email. This is the basic setup for connecting to your Powerwall. ```python pw = pypowerwall.Powerwall(host="", password="", email="") ``` -------------------------------- ### Get Vitals Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Retrieves vital system metrics. Refer to the provided example for the detailed output structure. ```APIDOC ## GET /api/vitals ### Description Retrieves vital system metrics. ### Method GET ### Endpoint /api/vitals ### Response #### Success Response (200) - Refer to the example output for the detailed structure of the response. ### Response Example [Link to example output](https://github.com/jasonacox/pypowerwall/blob/main/docs/vitals-example.json) ``` -------------------------------- ### Get Site Name Source: https://github.com/jasonacox/pypowerwall/blob/main/API.md Retrieve the registered name of the Powerwall installation site. Returns None if the name cannot be determined. ```python pw.site_name() ``` -------------------------------- ### Combine Multiple Powerwall Settings Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Apply multiple configuration settings in a single command for efficiency. This example sets the mode to self-consumption, reserve to 20%, and disables grid charging. ```bash python -m pypowerwall set -mode self_consumption -reserve 20 -gridcharging off ``` -------------------------------- ### Get Combined Power Across All Gateways Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/server/README.md Calculate and retrieve the total power flow aggregated across all configured gateways. This is useful for understanding the overall energy status of a multi-system setup. ```http GET /api/aggregate/power ``` -------------------------------- ### Setup and Run Custom Docker Container Source: https://github.com/jasonacox/pypowerwall/blob/main/pwsimulator/README.md Sets up and runs a custom-built pyPowerwall simulator Docker container, mapping port 443 for HTTPS access. Ensure the image is built first using `docker build`. ```bash docker run \ -d \ -p 443:443 \ --name pwsimulator \ --restart unless-stopped \ pwsimulator ``` -------------------------------- ### Powerwall Class Initialization Source: https://context7.com/jasonacox/pypowerwall/llms.txt Demonstrates how to initialize the `Powerwall` class for various connection modes and configurations. ```APIDOC ## `Powerwall(...)` — Initialization The main class that connects to a Powerwall system. Accepts credentials, host, timezone, and mode-selection flags. When `auto_select=True`, it tries modes in order (FleetAPI → Cloud → TEDAPI → Local) and uses the first that succeeds. ### Option 1: Local mode (Powerwall 2 / Powerwall+) ```python import pypowerwall pw = pypowerwall.Powerwall( host="10.0.1.99", password="yourpassword", # Customer password (last 5 chars of gateway password) email="user@example.com", timezone="America/Los_Angeles", pwcacheexpire=5, # Cache API responses for 5 seconds timeout=5, poolmaxsize=10, authmode="cookie" # "cookie" (default) or "token" ) ``` ### Option 2: Tesla FleetAPI (official, requires prior setup) ```python pw = pypowerwall.Powerwall(host="", password="", email="user@example.com", timezone="America/Los_Angeles", fleetapi=True) ``` ### Option 3: Tesla Cloud (Owners API, requires prior setup) ```python pw = pypowerwall.Powerwall(host="", password="", email="user@example.com", timezone="America/Los_Angeles", cloudmode=True) ``` ### Option 4: TEDAPI Wi-Fi (full mode — Powerwall 2, +, 3 over Wi-Fi) ```python pw = pypowerwall.Powerwall( host="192.168.91.1", gw_pwd="ABCDEFGHIJ", # Full gateway Wi-Fi password from QR sticker password="", email="", timezone="America/Los_Angeles" ) ``` ### Option 5: v1r LAN (Powerwall 3 over wired Ethernet, requires RSA key) ```python pw = pypowerwall.Powerwall( host="10.42.1.40", # Vendor subnet IP (not home LAN IP) gw_pwd="ABCDEXXXXX", # Last 5 chars auto-derived for /api/login/Basic rsa_key_path="/path/to/tedapi_rsa_private.pem", timezone="America/Los_Angeles" ) ``` ### Auto-select: tries all configured modes, picks best available ```python pw = pypowerwall.Powerwall(host, password, email, timezone, gw_pwd=gw_pwd, rsa_key_path=rsa_key_path, auto_select=True) print("Connected:", pw.is_connected()) # Connected: True ``` ``` -------------------------------- ### Get Max Backup (No Active Event) Source: https://github.com/jasonacox/pypowerwall/blob/main/proxy/API.md Sample JSON response for GET /control/max_backup when no active backup event is scheduled. ```json {"manual_backup": null, "backup_events": []} ``` -------------------------------- ### Get Max Backup (Active Event) Source: https://github.com/jasonacox/pypowerwall/blob/main/proxy/API.md Sample JSON response for GET /control/max_backup when an active backup event is scheduled. ```json {"manual_backup": {"start_time": 1772813197, "duration_seconds": 3600, "end_time": 1772816797, "active": true, "priority": 18446744073709551615}, "backup_events": []} ``` -------------------------------- ### Migrating from Old Proxy to New Server Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/server/README.md Steps to stop the old proxy and start the new PyPowerwall server, including environment variable configuration. ```bash # Stop old proxy docker stop pypowerwall-proxy # Start new server (same port) docker run -d \ --name pypowerwall-server \ -p 8675:8080 \ -e PW_HOST=192.168.91.1 \ -e PW_GW_PWD=your_gateway_password \ jasonacox/pypowerwall-server ``` -------------------------------- ### Building and Running Docker Image Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/server/README.md Commands to build the Docker image for the PyPowerwall server and run it as a container. ```bash docker build -t pypowerwall-server . docker run -p 8080:8080 pypowerwall-server ``` -------------------------------- ### Get Battery Reserve Percentage Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Retrieves the current battery reserve percentage. Set scale=True to get the value as displayed in the Tesla app. ```python get_reserve(scale) ``` -------------------------------- ### Clone Powerwall Dashboard Setup Files Source: https://github.com/jasonacox/pypowerwall/wiki/Powerwall-Dashboard Use this command to download the necessary files for the Powerwall monitoring dashboard. ```bash # Pull the Powerwall Dashboard Setup files git clone https://github.com/jasonacox/powerwall_monitor.git ``` -------------------------------- ### Get Power Summary using cURL Source: https://github.com/jasonacox/pypowerwall/blob/main/proxy/API.md A shortcut endpoint to get a combined power summary, likely including aggregates and other relevant power metrics. ```bash curl http://localhost:8675/pw/power ``` -------------------------------- ### Get System Status Source: https://github.com/jasonacox/pypowerwall/blob/main/API.md Retrieve the overall system status of the Powerwall. Optionally, specify a parameter to get a specific status value or format the output as JSON. ```python pw.status(param=None, jsonformat=False) ``` -------------------------------- ### Initialize pyPowerwall Connection Options Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Set up connection parameters for pyPowerwall, including different modes like LOCAL, FLEETAPI, CLOUD, TEDAPI, and v1r LAN TEDAPI. Ensure correct host, credentials, and timezone are provided. ```python import pypowerwall # Optional: Turn on Debug Mode # pypowerwall.set_debug(True) # Select option you wish to use. OPTION = 5 # Connect to Powerwall based on selected option if OPTION == 1: # Option 1 - LOCAL MODE - Customer Login (Powerwall 2 and Powerwall+ only) password="password" email="email@example.com" host = "10.0.1.123" # Address of your Powerwall Gateway timezone = "America/Los_Angeles" # Your local timezone gw_pwd = None rsa_key_path = None if OPTION == 2: # Option 2 - FLEETAPI MODE - Requires Setup (Powerwall & Solar-Only) host = password = email = "" timezone = "America/Los_Angeles" gw_pwd = None rsa_key_path = None if OPTION == 3: # Option 3 - CLOUD MODE - Requires Setup (Powerwall & Solar-Only) host = password = "" email='email@example.com' timezone = "America/Los_Angeles" gw_pwd = None rsa_key_path = None if OPTION == 4: # Option 4 - TEDAPI MODE - Requires access to Gateway (Powerwall 2, Powerwall+, and Powerwall 3) host = "192.168.91.1" gw_pwd = "ABCDEFGHIJ" password = email = "" timezone = "America/Los_Angeles" rsa_key_path = None # Uncomment the following for hybrid mode (Powerwall 2 and +) #password="password" #email="email@example.com" if OPTION == 5: # Option 5 - v1r LAN TEDAPI MODE - Powerwall 3 wired LAN (requires RSA key registration) host = "10.0.1.50" # Powerwall wired LAN IP (vendor subnet) gw_pwd = "ABCDEXXXXX" # Full gateway password from QR sticker (last 5 auto-derived) password = "" # Not needed — auto-derived from gw_pwd email = "" timezone = "America/Los_Angeles" rsa_key_path = "/path/to/tedapi_rsa_private.pem" # From v1r_register.py # Note on gw_pwd (Gateway Password) # - `gw_pwd` is the full Gateway Wi‑Fi password printed on the QR label. # - Used directly for TEDAPI HTTP Basic Auth in mode 4 (WiFi). # - In v1r mode (mode 5), the last 5 characters are auto-derived for /api/login/Basic. # - You only need to set `gw_pwd` — setting `password` separately is optional (backward compatible). # - If you set `gw_pwd` and leave `password` empty, pyPowerwall will: # - Auto-enable full TEDAPI mode (mode 4) if no `rsa_key_path` is set. # - Auto-enable v1r mode (mode 5) if `rsa_key_path` is set (derives last 5 chars). # - On Powerwall 2/+ you can set both `password`/`email` and `gw_pwd` for hybrid mode # that combines customer APIs with TEDAPI for supplemental vitals data. # # Note on rsa_key_path (v1r LAN TEDapi) # - Only needed for Powerwall 3 wired LAN access (mode 5) with full protobuf data. # - Requires RSA-4096 key pair registered via Tesla Owner API or Fleet API (see v1r_register.py). # - Without rsa_key_path, basic LAN mode still works for core power/battery/grid data. # Connect to Powerwall - auto_select mode (local, fleetapi, cloud, tedapi, v1r) pw = pypowerwall.Powerwall(host, password, email, timezone, gw_pwd=gw_pwd, rsa_key_path=rsa_key_path, auto_select=True) # Some System Info print("Site Name: %s - Firmware: %s - DIN: %s" % (pw.site_name(), pw.version(), pw.din())) print("System Uptime: %s\n" % pw.uptime()) # Pull Sensor Power Data grid = pw.grid() solar = pw.solar() battery = pw.battery() home = pw.home() ``` -------------------------------- ### Get Battery Power Level Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Retrieves the battery's power level. Set scale=True to get the value as displayed in the Tesla app, or scale=False for the actual level. ```python level(scale) ``` -------------------------------- ### Full v1r Python Example for Powerwall Access Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Demonstrates how to establish a connection to the Powerwall over v1r LAN using an RSA key and access various data points and API endpoints. Ensure the host IP, gateway password, and RSA key path are correctly configured. ```python import pypowerwall pw = pypowerwall.Powerwall( host="10.42.1.40", # Powerwall wired LAN IP (vendor subnet) gw_pwd="ABCDEXXXXX", # Full gateway password (last 5 auto-derived) email="user@example.com", timezone="America/Los_Angeles", rsa_key_path="/path/to/tedapi_rsa_private.pem" # RSA key from v1r_register.py ) # All standard methods work over v1r: print(pw.level()) # Battery percentage print(pw.power()) # {site, solar, battery, load} in watts print(pw.solar()) # Solar power in watts print(pw.battery()) # Battery power in watts print(pw.grid()) # Grid power in watts print(pw.load()) # Load power in watts print(pw.version()) # Firmware version print(pw.vitals()) # Per-device vitals (PVAC, PVS, TEPOD, PINV, etc.) print(pw.strings()) # Solar string data print(pw.alerts()) # Active device alerts # API polling: pw.poll(‘/api/meters/aggregates’) # Detailed meter data pw.poll(‘/api/system_status/soe’) # Battery state of energy pw.poll(‘/api/system_status/grid_status’) # Grid connection status pw.poll(‘/api/system_status’) # Full system status pw.poll(‘/api/site_info’) # Site configuration pw.poll(‘/api/operation’) # Operation mode ``` -------------------------------- ### Install Test Dependencies Source: https://github.com/jasonacox/pypowerwall/blob/main/CONTRIBUTING.md Install additional Python packages required for running unit tests, such as pytest and mock libraries. This is necessary for contributors who plan to run or write tests. ```bash pip install -r test_requirements.txt ``` -------------------------------- ### Get Load Sensor Data Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Retrieves sensor data for the home load. Set verbose=True to get raw JSON data; otherwise, it returns the power in Watts (W). ```python load(verbose) ``` -------------------------------- ### Powerwall Initialization Source: https://github.com/jasonacox/pypowerwall/blob/main/API.md Instantiate the Powerwall class with gateway details and optional configuration parameters. ```APIDOC ## Powerwall Initialization ### Description Instantiate the Powerwall class with gateway details and optional configuration parameters. ### Parameters - `host` (str) - Required - Hostname or IP of the Tesla gateway - `password` (str) - Required - Customer password for gateway - `email` (str) - Required - Customer email for gateway/cloud - `timezone` (str) - Optional - Timezone string - `pwcacheexpire` (int) - Optional - API cache timeout in seconds - `timeout` (int) - Optional - HTTPS call timeout in seconds - `poolmaxsize` (int) - Optional - HTTP connection pool size - `cloudmode` (bool) - Optional - Use Tesla cloud API (default: False) - `siteid` (str) - Optional - Site ID for cloud mode - `authpath` (str) - Optional - Path to cloud auth/site files - `authmode` (str) - Optional - "cookie" or "token" (default: "cookie") - `cachefile` (str) - Optional - Path to cache file - `fleetapi` (bool) - Optional - Use Tesla FleetAPI (default: False) - `auto_select` (bool) - Optional - Auto-select best connection mode - `retry_modes` (bool) - Optional - Retry connection attempts - `gw_pwd` (str) - Optional - Full gateway password from QR sticker - `rsa_key_path` (str) - Optional - Path to RSA-4096 private key for v1r LAN TEDAPI mode ``` -------------------------------- ### Configure Network Robustness Source: https://github.com/jasonacox/pypowerwall/blob/main/proxy/README.md Example Docker run command demonstrating configuration for poor network conditions using environment variables. ```bash docker run \ -d \ -p 8675:8675 \ -e PW_HOST='192.168.91.1' \ -e PW_GW_PWD='Gateway_Password' \ -e PW_TIMEOUT='3' \ -e PW_SUPPRESS_NETWORK_ERRORS='yes' \ -e PW_FAIL_FAST='yes' \ -e PW_CACHE_TTL='60' \ --name pypowerwall \ --restart unless-stopped \ jasonacox/pypowerwall ``` -------------------------------- ### Get Powerwall Status via CLI (Bash) Source: https://github.com/jasonacox/pypowerwall/blob/main/RELEASE.md This command shows how to use the pypowerwall CLI to get the status of a Powerwall in local mode, specifying the host IP address and password. ```bash python -m pypowerwall get -host 10.1.2.3 -password 'myPassword' ``` -------------------------------- ### Initialize Powerwall Connection Source: https://context7.com/jasonacox/pypowerwall/llms.txt Instantiate the Powerwall class with appropriate credentials and connection details for different access modes. Use `auto_select=True` to let the library choose the best available mode. ```python import pypowerwall # Option 1: Local mode (Powerwall 2 / Powerwall+) pw = pypowerwall.Powerwall( host="10.0.1.99", password="yourpassword", # Customer password (last 5 chars of gateway password) email="user@example.com", timezone="America/Los_Angeles", pwcacheexpire=5, # Cache API responses for 5 seconds timeout=5, poolmaxsize=10, authmode="cookie" # "cookie" (default) or "token" ) ``` ```python # Option 2: Tesla FleetAPI (official, requires prior setup) pw = pypowerwall.Powerwall(host="", password="", email="user@example.com", timezone="America/Los_Angeles", fleetapi=True) ``` ```python # Option 3: Tesla Cloud (Owners API, requires prior setup) pw = pypowerwall.Powerwall(host="", password="", email="user@example.com", timezone="America/Los_Angeles", cloudmode=True) ``` ```python # Option 4: TEDAPI Wi-Fi (full mode — Powerwall 2, +, 3 over Wi-Fi) pw = pypowerwall.Powerwall( host="192.168.91.1", gw_pwd="ABCDEFGHIJ", # Full gateway Wi-Fi password from QR sticker password="", email="", timezone="America/Los_Angeles" ) ``` ```python # Option 5: v1r LAN (Powerwall 3 over wired Ethernet, requires RSA key) pw = pypowerwall.Powerwall( host="10.42.1.40", # Vendor subnet IP (not home LAN IP) gw_pwd="ABCDEXXXXX", # Last 5 chars auto-derived for /api/login/Basic rsa_key_path="/path/to/tedapi_rsa_private.pem", timezone="America/Los_Angeles" ) ``` ```python # Auto-select: tries all configured modes, picks best available pw = pypowerwall.Powerwall(host, password, email, timezone, gw_pwd=gw_pwd, rsa_key_path=rsa_key_path, auto_select=True) ``` ```python print("Connected:", pw.is_connected()) # Connected: True ``` -------------------------------- ### Get Site Sensor Data Source: https://github.com/jasonacox/pypowerwall/blob/main/API.md Retrieve sensor data related to the power site. Set `verbose` to True to get raw JSON data instead of power values in Watts. ```python pw.site(verbose=False) ``` -------------------------------- ### Set Up Virtual Environment Source: https://github.com/jasonacox/pypowerwall/blob/main/CONTRIBUTING.md Create and activate a Python virtual environment to manage project dependencies. This isolates project packages from your global Python installation. ```bash python3 -m venv venv source venv/bin/activate ``` -------------------------------- ### Stop and Start Docker Container Source: https://github.com/jasonacox/pypowerwall/blob/main/pwsimulator/README.md Commands to stop and start a Docker container named 'pypowerwall'. Use these if you encounter Python errors and need to restart the server after editing configuration files. ```bash # Stop the server docker stop pypowerwall # Start the server docker start pypowerwall ``` -------------------------------- ### Get Battery Sensor Data Source: https://github.com/jasonacox/pypowerwall/blob/main/API.md Retrieve sensor data related to the battery's performance. Set `verbose` to True to get raw JSON data instead of power values in Watts. ```python pw.battery(verbose=False) ``` -------------------------------- ### Powerwall Class Initialization Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Instantiate the Powerwall class with connection and configuration parameters. Required parameters include host, password, and email. Optional parameters control cache, timeouts, and connection modes. ```python Powerwall(host, password, email, timezone, pwcacheexpire, timeout, poolmaxsize, cloudmode, siteid, authpath, authmode, cachefile, fleetapi, auto_select, retry_modes, gw_pwd, rsa_key_path) ``` -------------------------------- ### Get Solar Sensor Data Source: https://github.com/jasonacox/pypowerwall/blob/main/API.md Retrieve sensor data related to solar energy production. Set `verbose` to True to get raw JSON data instead of power values in Watts. ```python pw.solar(verbose=False) ``` -------------------------------- ### Initialize Powerwall Instance (Advanced) Source: https://github.com/jasonacox/pypowerwall/blob/main/API.md Initialize the Powerwall class with advanced configuration options. This allows for fine-tuning connection parameters, cache settings, and authentication modes. ```python pw = pypowerwall.Powerwall( host="", password="", email="", timezone="America/Los_Angeles", pwcacheexpire=5, timeout=5, poolmaxsize=10, cloudmode=False, siteid=None, authpath="", authmode="cookie", cachefile=".powerwall", fleetapi=False, auto_select=False, retry_modes=False, gw_pwd=None, rsa_key_path=None ) ``` -------------------------------- ### Get Load Sensor Data Source: https://github.com/jasonacox/pypowerwall/blob/main/API.md Retrieve sensor data related to the household's energy consumption. Set `verbose` to True to get raw JSON data instead of power values in Watts. ```python pw.load(verbose=False) ``` -------------------------------- ### Environment Variables for Single Gateway Mode (With Cloud Control) Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/server/README.md Configure the server for a single Powerwall gateway with cloud control capabilities. Requires TEDAPI credentials and Tesla Cloud authentication files. ```bash PW_HOST=192.168.91.1 PW_GW_PWD=your_gateway_password # For TEDAPI data reads PW_EMAIL=your-tesla-account@email.com PW_AUTHPATH=/path/to/auth/files # Directory with .pypowerwall.auth/.site PW_TIMEZONE=America/Los_Angeles ``` -------------------------------- ### Perform One-time Cloud Authentication Setup Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/server/README.md Run this Python command to initiate the Tesla Cloud authentication process. It opens a browser for authentication and generates necessary token files. ```bash python3 -m pypowerwall setup ``` -------------------------------- ### New TEDAPI Class Usage (Python) Source: https://github.com/jasonacox/pypowerwall/blob/main/RELEASE.md Demonstrates how to instantiate the new TEDAPI class and retrieve configuration and status data. It also shows how to parse and print meter aggregates, including location and real power in Watts. ```python # New TEDAPI Class import pypowerwall.tedapi tedapi = pypowerwall.tedapi.TEDAPI("GW_PASSWORD") config = tedapi.get_config() status = tedapi.get_status() meterAggregates = status.get('control', {}).get('meterAggregates', []) for meter in meterAggregates: location = meter.get('location', 'Unknown').title() realPowerW = int(meter.get('realPowerW', 0)) print(f" - {location}: {realPowerW}W") ``` -------------------------------- ### site_name() Source: https://github.com/jasonacox/pypowerwall/blob/main/API.md Retrieves the name of the Powerwall installation site. ```APIDOC ## site_name() ### Description Returns the site name. ### Returns - str/None: The name of the site, or None if not available. ``` -------------------------------- ### Run TesSolarCharge.py Script Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/README.md Execute the TesSolarCharge.py script to begin charging your car and dynamically adjust charging rates based on solar energy availability. ```bash # Run TesSolarCharge.py to start charging your car and adjusting rate based on solar python3 TesSolarCharge.py ``` -------------------------------- ### Connect to Gateway and Display Power Data using TEDAPI Library Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/tedapi/README.md Use the TEDAPI class from the pypowerwall library to connect to the gateway, retrieve configuration and live status, and print site information and meter data. ```python # Import Class from pypowerwall.tedapi import TEDAPI gw_pwd = "THEGWPASS" # Connect to Gateway gw = TEDAPI(gw_pwd) # Grab the Config and Live Status config = gw.get_config() status = gw.get_status() # Print site_info = config.get('site_info', {}) or {} site_name = site_info.get('site_name', 'Unknown') print(f"My Site: {site_name}") meterAggregates = status.get('control', {}).get('meterAggregates', []) for meter in meterAggregates: location = meter.get('location', 'Unknown').title() realPowerW = int(meter.get('realPowerW', 0)) print(f" - {location}: {realPowerW}W") ``` -------------------------------- ### Get Reserve Source: https://github.com/jasonacox/pypowerwall/blob/main/proxy/API.md Retrieves the current battery reserve percentage. ```APIDOC ## GET /control/reserve ### Description Gets the current battery reserve percentage. ### Method GET ### Endpoint /control/reserve?token= ### Parameters #### Query Parameters - **token** (string) - Required - The secret token for authentication. ``` -------------------------------- ### Get Operating Mode Source: https://github.com/jasonacox/pypowerwall/blob/main/proxy/API.md Retrieves the current operating mode of the Powerwall. ```APIDOC ## GET /control/mode ### Description Gets the current operating mode of the Powerwall. ### Method GET ### Endpoint /control/mode?token= ### Parameters #### Query Parameters - **token** (string) - Required - The secret token for authentication. ``` -------------------------------- ### Run Simple Test Proxy for TEDAPI Data Source: https://github.com/jasonacox/pypowerwall/blob/main/tools/tedapi/README.md Execute the web.py script to start a prototype web proxy that accesses and displays TEDAPI data. Access data via http://localhost:4444. ```bash # Run Simple Test Proxy python3 web.py ``` -------------------------------- ### Get Powerwall Alerts Source: https://github.com/jasonacox/pypowerwall/blob/main/README.md Retrieves an array of current alerts from the Powerwall devices. ```python alerts() ```