pypowerwall

Python API for Tesla Powerwall and Solar Power Data

MIT License

Downloads
1.4K
Stars
135
Committers
18
pypowerwall - v0.11.1 - PW3 and FleetAPI Bugfix Latest Release

Published by jasonacox about 2 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.11.0...v0.11.1

pypowerwall - v0.11.0 - Add PW3 Vitals

Published by jasonacox about 2 months ago

What's Changed

  • Add PW3 Vitals by @jasonacox in https://github.com/jasonacox/pypowerwall/pull/110
  • Add polling of Powerwall 3 Devices to pull in PW3 specific string data, PW capacity, voltages, frequencies, and alerts.
  • This creates TEPOD, PVAC and PVS compatible payloads available in vitals().

Proxy URLs updated for PW3:

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.10...v0.11.0

pypowerwall - v0.10.10 - Add Grid Control

Published by jasonacox 2 months ago

What's Changed

Command Line Examples

# 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

Programming Examples

import pypowerwall

# FleetAPI Mode
PW_HOST=""
PW_EMAIL="[email protected]"
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)

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.9...v0.10.10

pypowerwall - v0.10.9 - TEDAPI Voltage & Current

Published by jasonacox 3 months ago

What's Changed

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.8...v0.10.9

pypowerwall - v0.10.8 - Firmware Version for TEDAPI

Published by jasonacox 4 months ago

What's Changed

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.7...v0.10.8

pypowerwall - v0.10.7 - FleetAPI Energy History

Published by jasonacox 4 months ago

What's Changed

import pypowerwall

pw = pypowerwall.Powerwall(host=PW_HOST, email=PW_EMAIL, fleetapi=True)
pw.client.fleet.get_calendar_history(kind="soe")
pw.client.fleet.get_history(kind="power")

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.6...v0.10.7

pypowerwall - v0.10.6 - pyLint Cleanup

Published by jasonacox 4 months ago

What's Changed

  • Address pyLint cleanup and minor bug fixes by @jasonacox in https://github.com/jasonacox/pypowerwall/pull/103
  • TEDAPI get_reserve() fix to address unscaled battery backup reserve level results.
  • Address pyLint Cleanup of Code.
  • Proxy: Command mode error handling.
  • Cloud Mode: Fix logic for selecting FleetAPI mode
  • Add request timeout settings to FleetAPI and TEDAPI calls.

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.5...v0.10.6

pypowerwall - v0.10.5 - Minor Fixes

Published by jasonacox 4 months ago

What's Changed

  • v0.10.5 - Minor Fixes by @jasonacox in https://github.com/jasonacox/pypowerwall/pull/102
  • Fix for TEDAPI "full" (e.g. Powerwall 3) mode, including grid_status bug resulting in false reports of grid status, level() bug where data gap resulted in 0% state of charge and alerts() where data gap from tedapi resulted in a null alert.
  • Add TEDAPI API call locking to limit load caused by concurrent polling.
  • Proxy - Add battery full_pack and remaining energy data to /pod API call for all cases.

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.4...v0.10.5

pypowerwall - 0.10.4 - Powerwall 3 Local API Support

Published by jasonacox 5 months ago

What's Changed

  • Add Powerwall 3 Local API Support by @jasonacox in https://github.com/jasonacox/pypowerwall/pull/101
  • TEDAPI will activate in hybrid (using TEDAPI for vitals and existing local APIs for other metrics) or full (all data from TEDAPI) mode to provide better Powerwall 3 support.
  • The full mode will automatically activate when the customer password is blank and gw_pwd is set.
  • Note: The full mode will provide less metrics than hybrid mode since Powerwall 2/+ systems have additional APIs that are used in hybrid mode to fetch additional data
import pypowerwall

# Activate HYBRID mode (for Powerwall / 2 / + systems)
pw = pypowerwall.Powerwall("192.168.91.1", password=PASSWORD, email=EMAIL, gw_pwd=PW_GW_PWD)

# Activate FULL mode (for all systems including Powerwall 3)
pw = pypowerwall.Powerwall("192.168.91.1", gw_pwd=PW_GW_PWD)

Related:

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.3...v0.10.4

pypowerwall - v0.10.3 - TEDAPI Connect Update

Published by jasonacox 5 months ago

What's Changed

  • v0.10.3 - TEDAPI Connect by @jasonacox in https://github.com/jasonacox/pypowerwall/pull/100
  • Update setup.py to include dependencies on protobuf>=3.20.0.
  • Fix TEDAPI connect() logic error to better validate PW3 Gateway endpoint access as raised in #97 by @ttl74ls100
  • Add documentation for TEDAPI setup.
  • Update CLI to support TEDAPI calls.
  • Proxy t60 - Fix edge case where /csv API will error due to NoneType inputs.
  • Add TEDAPI argument to set custom GW IP address.
# Connect to TEDAPI and pull data
python3 -m pypowerwall tedapi

# Direct call to TEDAPI class test function (optional password)
python3 -m pypowerwall.tedapi GWPASSWORD
python3 -m pypowerwall.tedapi --debug
python3 -m pypowerwall.tedapi --gw_ip 192.168.91.1 --debug

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.2...v0.10.3

pypowerwall - v0.10.2 - FleetAPI Hotfix

Published by jasonacox 5 months ago

What's Changed

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.1...v0.10.2

pypowerwall - v0.10.1 - TEDAPI Vitals Hotfix

Published by jasonacox 5 months ago

What's Changed

  • v0.10.1 - TEDAPI Vitals Hotfix by @jasonacox in https://github.com/jasonacox/pypowerwall/pull/96
  • Fix PVAC lookup error logic in TEDAPI class vitals() function.
  • Add alerts and other elements to PVAC TETHC TESYNC vitals.
  • Update vitals Neurio block to include correct location and adjust RealPower based on power scale factor.

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.0...v0.10.1

pypowerwall - v0.10.0 - New Device Vitals

Published by jasonacox 5 months ago

What's Changed

  • v0.10.0 - New Device Vitals by @jasonacox in https://github.com/jasonacox/pypowerwall/pull/95
  • Add support for /tedapi API access on Gateway (requires connectivity to 192.168.91.1 GW and Gateway Password) with access to "config" and "status" data.
  • Adds drop-in replacement for depreciated /vitals API and payload using the new TEDAPI class. This allows easy access to Powerwall device vitals.
  • Proxy update to t58 to support TEDAPI with environmental variable PW_GW_PWD for Gateway Password. Also added FleetAPI, Cloud and TEDAPI specific GET calls, /fleetapi, /cloud, and /tedapi respectively.
# How to Activate the TEDAPI Mode
import pypowerwall

# You will need the Gateway/WiFi Password usually found on QR code on Gateway (not the customer password)
gw_pwd = "GW_PASSWORD" 

# Direct Connect to GW
host = "192.168.91.1" 
pw = pypowerwall.Powerwall(host,password,email,timezone,gw_pwd=gw_pwd)
print(pw.vitals())
# 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")

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.9.1...v0.10.0

pypowerwall - v0.9.1 - Bug Fixes and Updates

Published by jasonacox 5 months ago

What's Changed

python -m pypowerwall get -host 10.1.2.3 -password 'myPassword'

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.9.0...v0.9.1

pypowerwall - v0.9.0 - FleetAPI Support

Published by jasonacox 5 months ago

What's Changed

  • v0.9.0 - Tesla (official) FleetAPI cloud mode support by @jasonacox in https://github.com/jasonacox/pypowerwall/pull/91 - This adds the FleetAPI class and mapping for pypowerwall.
  • FleetAPI setup provided by module CLI: python -m pypowerwall fleetapi
  • Adds auto_select mode for instatiating a Powerwall connection: local mode, fleetapi mode and cloud mode. Provides pw.mode class variable as the mode selected.
    import pypowerwall

    # Option 1 - LOCAL MODE - Credentials for your Powerwall - Customer Login
    password="password"
    email="[email protected]"
    host = "10.0.1.123"               # Address of your Powerwall Gateway
    timezone = "America/Los_Angeles"  # Your local timezone

    # Option 2 - FLEETAPI MODE - Requires Setup
    host = password = email = ""
    timezone = "America/Los_Angeles" 

    # Option 3 - CLOUD MODE - Requires Setup
    host = password = ""
    email='[email protected]'
    timezone = "America/Los_Angeles"
 
    # Connect to Powerwall - auto_select mode (local, fleetapi, cloud)
    pw = pypowerwall.Powerwall(host,password,email,timezone,auto_select=True)

    print(f"Connected to Powerwall with mode: {pw.mode}")

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.8.5...v0.9.0

pypowerwall - v0.8.5 - Solar Only Fix

Published by jasonacox 5 months ago

What's Changed

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.8.4...v0.8.5

pypowerwall - v0.8.4 - Set Reserve

Published by jasonacox 6 months ago

What's Changed

Proxy t55 (4 May 2024)

  • Fix /pod API to add time_remaining_hours and backup_reserve_percent for cloud mode.
  • Replaced t54 - Move control to POST per @KevM in https://github.com/jasonacox/pypowerwall/issues/87
  • Added GET APIs to retrieve backup reserve and operating mode settings
  • Added POST command APIs to set backup reserve and operating mode settings. Requires setting PW_CONTROL_SECRET for the proxy. Use with caution.
# Set Mode
export MODE=self_consumption
export RESERVE=20
export PW_CONTROL_SECRET=mySecretKey

curl -X POST -d "value=$MODE&token=$PW_CONTROL_SECRET" http://localhost:8675/control/mode

# Set Reserve
curl -X POST -d "value=$RESERVE&token=$PW_CONTROL_SECRET" http://localhost:8675/control/reserve

# Read Settings
curl http://localhost:8675/control/mode
curl http://localhost:8675/control/reserve

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.8.3...v0.8.4

pypowerwall - v0.8.3 - Control APIs

Published by jasonacox 7 months ago

What's Changed

Proxy (t54):

  • Fix /pod API to add time_remaining_hours and backup_reserve_percent for cloud mode.
  • Added control APIs to set backup reserve and operating mode settings. Requires setting PW_CONTROL_SECRET. Use with caution! #79
# Set Mode
curl "http://localhost:8675/control/mode?token=$PW_CONTROL_SECRET&value=self_consumption"

# Set Reserve
curl "http://localhost:8675/control/reserve?token=$PW_CONTROL_SECRET&value=20"

# Omit Value to Read Settings
curl "http://localhost:8675/control/mode?token=$PW_CONTROL_SECRET"
curl "http://localhost:8675/control/reserve?token=$PW_CONTROL_SECRET"

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.8.2...v0.8.3

pypowerwall - v0.8.2

Published by jasonacox 7 months ago

What's Changed

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.8.1...v0.8.2

pypowerwall - v0.8.1 - Set battery reserve, operation mode

Published by jasonacox 7 months ago

What's Changed

  • v0.8.1 - Set battery reserve, operation mode by @emptywee in https://github.com/jasonacox/pypowerwall/pull/78
  • Added get_mode(), set_mode(),set_reserve(),and set_operation() function to set battery operation mode and/or reserve level by @emptywee in https://github.com/jasonacox/pypowerwall/pull/78. Likely won't work in the local mode.
  • Added basic validation for main class __init__() parameters (a.k.a. user input).
  • Better handling of 401/403 errors from Powerwall in local mode.
  • Handle 50x errors from Powerwall in local mode.
  • Added Alerts for Grid Status alerts().
  • New command line functions (set and get):
usage: PyPowerwall [-h] {setup,scan,set,get,version} ...

PyPowerwall Module v0.8.1

options:
  -h, --help            show this help message and exit

commands (run <command> -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

Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.8.0...v0.8.1