Python API for Tesla Powerwall and Solar Power Data
MIT License
Published by jasonacox about 2 months ago
Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.11.0...v0.11.1
Published by jasonacox about 2 months ago
Proxy URLs updated for PW3:
Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.10...v0.11.0
Published by jasonacox 2 months ago
# 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
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
Published by jasonacox 3 months ago
/api/meters/aggregates
from TEDAPI status data by @jasonacox in https://github.com/jasonacox/pypowerwall/pull/107
num_meters_aggregated
calculation in aggregates.Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.8...v0.10.9
Published by jasonacox 4 months ago
get_firmware_version()
to poll Powerwall for firmware version. Discovered by @geptto in https://github.com/jasonacox/pypowerwall/issues/97. This function has been integrated into pypowerwall existing APIs (e.g. pw.version()
)get_components()
and get_battery_block()
functions which provide additional Powerwall 3 related device vital information for Powerwall 3 owners. Discovered by @lignumaqua in https://github.com/jasonacox/Powerwall-Dashboard/discussions/392#discussioncomment-9864364. The plan it to integrate this data into the other device vitals payloads for PW3 systems (TODO).Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.7...v0.10.8
Published by jasonacox 4 months ago
get_history()
and get_calendar_history()
to return energy, power, soe, and other history data.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
Published by jasonacox 4 months ago
Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.5...v0.10.6
Published by jasonacox 4 months ago
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./pod
API call for all cases.Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.4...v0.10.5
Published by jasonacox 5 months ago
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.full
mode will automatically activate when the customer password
is blank and gw_pwd
is set.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 dataimport 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
Published by jasonacox 5 months ago
setup.py
to include dependencies on protobuf>=3.20.0
.connect()
logic error to better validate PW3 Gateway endpoint access as raised in #97 by @ttl74ls100/csv
API will error due to NoneType inputs.# 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
Published by jasonacox 5 months ago
Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.1...v0.10.2
Published by jasonacox 5 months ago
Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.10.0...v0.10.1
Published by jasonacox 5 months ago
/tedapi
API access on Gateway (requires connectivity to 192.168.91.1 GW and Gateway Password) with access to "config" and "status" data./vitals
API and payload using the new TEDAPI class. This allows easy access to Powerwall device vitals.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
Published by jasonacox 5 months ago
site_id
as raised by @darroni in https://github.com/jasonacox/pypowerwall/issues/93
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
Published by jasonacox 5 months ago
python -m pypowerwall fleetapi
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
Published by jasonacox 5 months ago
Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.8.4...v0.8.5
Published by jasonacox 6 months ago
set_reserve(level)
logic to handle levels from 0 to 100. Identified by @spoonwzd in #85/pod
API to add time_remaining_hours
and backup_reserve_percent
for cloud mode.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
Published by jasonacox 7 months ago
Proxy (t54):
/pod
API to add time_remaining_hours
and backup_reserve_percent
for cloud mode.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
Published by jasonacox 7 months ago
Full Changelog: https://github.com/jasonacox/pypowerwall/compare/v0.8.1...v0.8.2
Published by jasonacox 7 months ago
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.__init__()
parameters (a.k.a. user input).alerts()
.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