- TEDAPI: Fix bug with activeAlerts logic causing errors on systems with multiple Powerwall 3's. Identified by @rmotapar in jasonacox/Powerwall-Dashboard#387 (comment)
- FleetAPI: Fix connect() to handle non-energy products in the getsites response. Identified by @gregrahn in #111
- Add polling of Powerwall 3 Devices to pull in PW3 specific string data, capacity, voltages, frequencies, and alerts.
- This creates mock TEPOD, PVAC and PVS compatible payloads available in vitals().
Proxy URLs updated for PW3:
- http://localhost:8675/vitals
- http://localhost:8675/help (verify pw3 shows True)
- http://localhost:8675/tedapi/components
- http://localhost:8675/tedapi/battery
- Add a function and command line options to allow user to get and set grid charging and exporting modes (see #108).
- Supports FleetAPI and Cloud modes only (not Local mode)
# 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)
- Add computed voltage and current to
/api/meters/aggregates
from TEDAPI status data. - Fix error in
num_meters_aggregated
calculation in aggregates.
- Add TEDAPI
get_firmware_version()
to poll Powerwall for firmware version. Discovered by @geptto in #97. This function has been integrated into pypowerwall existing APIs (e.g.pw.version()
) - Add TEDAPI
get_components()
andget_battery_block()
functions which providing additional Powerwall 3 related device vital information for Powerwall 3 owners. Discovered by @lignumaqua in jasonacox/Powerwall-Dashboard#392 (comment). The plan it to integrate this data into the other device vitals payloads (TODO).
- FleetAPI - Add
get_history()
andget_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")
- Minor Bug Fixes - TEDAPI get_reserve() fix to address unscaled results.
- pyLint Cleanup of Code
- 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 andalerts()
where data gap from tedapi resulted in anull
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.
- Add local support for Powerwall 3 using TEDAPI.
- TEDAPI will activate in
hybrid
(using TEDAPI for vitals and existing local APIs for other metrics) orfull
(all data from TEDAPI) mode to provide better Powerwall 3 support. - The
full
mode will automatically activate when the customerpassword
is blank andgw_pwd
is set. - Note: The
full
mode will provide less metrics thanhybrid
mode since Powerwall 2/+ systems have additional APIs that are used inhybrid
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:
- Update
setup.py
to include dependencies onprotobuf>=3.20.0
. - Add TEDAPI
connect()
logic to better validate Gateway endpoint access. - 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
- Fix FleetAPI setup script as raised in #98.
- Update FleetAPI documentation and CLI usage.
- 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.
- 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
gw_pwd = "GW_PASSWORD" # Gateway Passowrd usually on QR code on Gateway
host = "192.168.91.1" # Direct Connect to GW
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")
- Fix bug in time_remaining_hours() and convert print statements in FleetAPI to log messages.
- Fix CLI bug related to
site_id
as raised by @darroni in #93 - Add CLI option for local mode to get status:
python -m pypowerwall get -host 10.1.2.3 -password 'myPassword'
- v0.9.0 - Tesla (official) FleetAPI cloud mode support by @jasonacox in #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 andcloud
mode. Providespw.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}")
- Fix bug with setup for certain Solar Only systems where setup process fails. Identified by @hulkster in jasonacox/Powerwall-Dashboard#475
- Updated
set_reserve(level)
logic to handle levels from 0 to 100. Identified by @spoonwzd in #85
- Added additional error handling logic to clean up exceptions.
- Proxy: Added command APIs for setting backup reserve and operating mode.
- Added 5 minute cooldown for HTTP 503 Service Unavailable errors from API calls.
- Proxy: Added DISABLED API handling logic.
- Added
get_mode()
,set_mode()
,set_reserve()
,andset_operation()
function to set battery operation mode and/or reserve level by @emptywee in #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
andget
):
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
- Refactored pyPowerwall by @emptywee in #77 including:
- Moved Local and Cloud based operation code into respective modules, providing better abstraction and making it easier to maintain and extend going forward.
- Made meaning of the
jsonformat
parameter consistent across all method calls (breaking API change). - Removed Python 2.7 support.
- Cleaned up code and adopted a more pythoinc style.
- Fixed battery_blocks() for non-vitals systems.
- Added logic to pull string data from
/api/solar_powerwall
API if vitals data is not available by @jasonacox in #76. - Added alerts from
/api/solar_powerwall
when vitals not present by @DerickJohnson in #75. The vitals API is not present in firmware versions > 23.44, this provides a workaround to get alerts. - Allow customization of the cachefile location and name by @emptywee in #74 via
cachefile
parameter.
# Example
import pypowerwall
pw = pypowerwall.Powerwall(
host="10.1.2.30",
password="secret",
email="[email protected]",
timezone="America/Los_Angeles",
pwcacheexpire=5,
timeout=5,
poolmaxsize=10,
cloudmode=False,
siteid=None,
authpath="",
authmode="cookie",
cachefile=".powerwall",
)
- Updated logic to disable vitals API calls for Firmware 23.44.0+
- Added rate limit detection and cooldown mode to allow Powerwall gateway time to recover.
- Add cache and extended TTL for 404 responses from Powerwall as identified in issue jasonacox/Powerwall-Dashboard#449. This will help reduce load on Powerwall gateway that may be causing rate limiting for some users (Firmware 23.44.0+).
- Bug fix for correct grid status for Solar-Only systems on
cloud mode
(see jasonacox/Powerwall-Dashboard#437)
- Fix enumeration of energy sites during
cloud mode
setup to handle incomplete sites with Unknown names or types by @dcgibbons in #72 - Proxy t41 Updates - Bug fixes for Solar-Only systems using
cloud mode
(see jasonacox/Powerwall-Dashboard#437).
- Proxy t40: Use /api/system_status battery blocks data to augment /pod and /freq macro data APIs by @jasonacox in #67 thanks to @ceeeekay in jasonacox/Powerwall-Dashboard#402 (comment)
- Network Scanner: Improve network scan speed by scanning multiple hosts simultaneously by @mcbirse in #67. The number of hosts to scan simultaneously can be adjusted using the optional
-hosts=
argument (default = 30, maximum = 100), e.g.python -m pypowerwall scan -hosts=50
- Fix Critical Bug - 404 HTTP Status Code Handling (Issue #65).
- Added optional email address argument to Cloud Mode setup (
python -m pypowerwall setup -email=<email>
) by @mcbirse in #64 to streamline Powerwall-Dashboard setup script. - Updated network scanner output to advise Powerwall 3 is supported in Cloud Mode by @mcbirse in #64
pyPowerwall Updates
- This release adds the ability to use a Bearer Token for Authentication for the local Powerwall gateway API calls. This is selectable by defining
authmode='token'
in the initialization. The default mode uses the existingAuthCookie
andUserRecord
method.
import pypowerwall
pw = pypowerwall.Powerwall(HOST, PASSWORD, EMAIL, TIMEZONE, authmode="token")
Proxy
- The above option is extended to the pyPowerwall Proxy via the environmental variable
PW_AUTH_MODE
set to cookie (default) or token.
Powerwall Network Scanner
- Added optional IP address argument to network scanner by @mcbirse in #63. The Scan Function can now accept an additional argument
-ip=
to override the host IP address detection (python -m pypowerwall scan -ip=192.168.1.100
). This may be useful where the host IP address/network cannot be detected correctly, for instance if pypowerwall is running inside a container.
- Setup will now check for
PW_AUTH_PATH
environmental variable to set the path for.pypowerwall.auth
and.pypowerwall.site
by @mcbirse in #62 - Proxy t37 - Move signal handler to capture SIGTERM when proxy halts due to config error by @mcbirse in #62. This ensures a containerized proxy will exit without delay when stopping or restarting the container.
- Add pypowerwall setting to define path to cloud auth cache and site files in the initialization. It will default to current directory.
- Add pypowerwall setting to define energy site id in the initialization. It will default to None.
import pypowerwall
pw = pypowerwall.Powerwall(email="[email protected]",cloudmode=True,siteid=1234567,authpath=".auth")
- Proxy will now use
PW_AUTH_PATH
as an environmental variable to set the path for.pypowerwall.auth
and.pypowerwall.site
. - Proxy also has
PW_SITEID
as an environmental variable to setsiteid
.
- Simulate Powerwall Energy Gateway via Tesla Cloud API calls. In
cloudmode
API calls to pypowerwall APIs will result in calls made to the Tesla API to fetch the data.
Cloud Mode Setup - Use pypowerwall to fetch your Tesla Owners API Token
python3 -m pypowerwall setup
# Token and site information stored in .pypowerwall.auth and .pypowerwall.site
Cloud Mode Code Example
import pypowerwall
pw = pypowerwall.Powerwall(email="[email protected]",cloudmode=True)
pw.power()
# Output: {'site': 2977, 'solar': 1820, 'battery': -3860, 'load': 937}
pw.poll('/api/system_status/soe')
# Output: '{"percentage": 26.403205103271222}'
- Added new API function to compute estimated backup time remaining on the battery:
get_time_remaining()
Proxy t29 Updates
- Default page rendered by proxy (http://pypowerwall:8675/) will render Powerflow Animation
- Animation assets (html, css, js, images, fonts, svg) will render from local filesystem instead of pulling from Powerwall TEG portal.
- Start prep for possible API removals from Powerwall TEG portal (see NOAPI settings)
Powerwall Network Scanner
- Adjust scan timeout default to 1,000ms (1s) to help with more consistent scans.
- Added scan detection for new Powerwall 3 systems. API discovery is still underway so pypowerwall currently does not support Powerwall 3s. See jasonacox/Powerwall-Dashboard#387
$ python3 -m pypowerwall scan
pyPowerwall Network Scanner [0.6.3]
Scan local network for Tesla Powerwall Gateways
Your network appears to be: 10.0.1.0/24
Enter Network or press enter to use 10.0.1.0/24:
Running Scan...
Host: 10.0.1.2 ... OPEN - Not a Powerwall
Host: 10.0.1.5 ... OPEN - Found Powerwall 3 [Currently Unsupported]
Host: 10.0.1.8 ... OPEN - Not a Powerwall
Host: 10.0.1.9 ... OPEN - Found Powerwall 3 [Currently Unsupported]
Done
Discovered 2 Powerwall Gateway
10.0.1.5 [Powerwall-3] Firmware Currently Unsupported - See https://tinyurl.com/pw3support
10.0.1.9 [Powerwall-3] Firmware Currently Unsupported - See https://tinyurl.com/pw3support
- Proxy t28: Add a
grafana-dark
style forPW_STYLE
settings to accommodate placing as iframe in newer Grafana versions (e.g. v9.4.14). See jasonacox/Powerwall-Dashboard#371.
- Add alert PVS_a036_PvArcLockout by @JordanBelford in #33
- Create
tessolarcharge.py
by @venturanc in #36 & #37 & #38 - Fix typos and spelling errors by @mcbirse in #40
- Add alert definitions per #42 by @jasonacox in #43
- Added two PVAC Alerts by @niabassey in #46
- Added Firmware 23.28.1 to README.md by @niabassey in #48
- Add proxy gracefully exit with SIGTERM by @rcasta74 in #49
- PyPI 0.6.2
- Update docs for alerts by @DerickJohnson in #29 and #30
- Fix Cache-Control no-cache header and allow for setting max-age, fixes #31 by @dkerr64 in #32
- PyPI 0.6.1
- Added new
SystemMicroGridFaulted
andSystemWaitForUser
grid conditions togrid_status()
function. Both are mapped to "DOWN" conditions. Discovery by @mcbrise in jasonacox/Powerwall-Dashboard#158 (comment). - Revised error handling of SITE_DATA request due to issues noted in #12 when multiple sites are linked to the Tesla account by @mcbirse in #25
- Proxy t24: Added new
/alerts/pw
endpoint with dictionary/object response format by @DerickJohnson in #26
- PyPI 0.6.0
- Added HTTP persistent connections for API requests to Powerwall Gateway by @mcbirse in #21
- Requests to Gateway will now re-use persistent http connections which reduces load and increases response time.
- Uses default connection
poolmaxsize=10
to align with Session object defaults. Note: pool use applies to multi-threaded use of pyPowerwall only, e.g. as with the pyPowerwall Proxy Server. - Added env
PW_POOL_MAXSIZE
to proxy server to allow this to be controlled (persistent connections disabled if set to zero). - Added env
PW_TIMEOUT
to proxy server to allow timeout on requests to be adjusted.
- PyPI 0.5.1
- Add FreeBSD-specific installation instructions by @zi0r in #18
- Add
grid_status()
responses for syncing to off-grid by @mcbirse in #19
- PyPI 0.5.0
- Added additional exception handling to help identify connection and login errors.
- Added
is_connected()
function to test for a successful connection to the Powerwall. - Added firmware version to command line network scan (
python -m pypowerwall scan
)
Proxy Server Updates (Build t16) - See here for more Proxy Release notes.
- Add support for backup switch by @nhasan in #12
- Add passthrough to Powerwall web interface and customize for iFrame displays by @danisla in #14
- Remove scrollbars from web view by @danisla in #15
- Add support for specifying a bind address by @zi0r in #16
- Add shebang for direct execution by @zi0r in #17
- PyPI 0.4.0
- Added parameter to
poll()
to force call (ignore cache) - Added
alerts()
function to return an array of device alerts. - Added
get_reserve()
function to return battery reserve setting. - Added
grid_status()
function to return state of grid. - Added
system_status()
function to return system status. - Added
battery_blocks()
function to return battery specific information. - Expanded class to include settings for cache expiration (
pwcacheexpire
) and connectiontimeout
.
# Force Poll
pw.poll('/api/system_status/soe',force=True)
'{"percentage":100}'
# Powerwall Alerts
pw.alerts()
['PodCommissionTime', 'GridCodesWrite', 'GridCodesWrite', 'FWUpdateSucceeded', 'THC_w155_Backup_Genealogy_Updated', 'PINV_a067_overvoltageNeutralChassis', 'THC_w155_Backup_Genealogy_Updated', 'PINV_a067_overvoltageNeutralChassis', 'PVS_a018_MciStringB', 'SYNC_a001_SW_App_Boot']
# Battery Reserve Setting
pw.get_reserve()
20.0
# State of Grid
pw.grid_status()
'UP'
- PyPI 0.3.0
- Added alerts and additional attributes from
vitals()
output. - Note: API change to
vitals()
output for dependant systems.
- PyPI 0.2.0
- Breaking change to Protobuf schema (PR #2) including:
- Files
tesla.proto
andtesla_pb2.py
- Impacted output from function
vitals()
and examples/vitals.py.
- PyPI 0.1.4
- Changed "Network Scan" default timeout to 400ms for better detection.
- Added Tesla App style "Battery Level Percentage" Conversion option to
level()
to convert the level reading to the 95% scale used by the App. This converts the battery level percentage to be consistent with the Tesla App:
>>> pw.level(scale=True)
39.971429212508326
>>> pw.level()
42.972857751882906
- PyPI 0.1.3
- Added
temp()
function to pull Powerwall temperatures.
pw.temps(jsonformat=True)
{
"TETHC--2012170-25-E--TGxxxxxxxxxxxx": 17.5,
"TETHC--3012170-05-B--TGxxxxxxxxxxxx": 17.700000000000003
}
- PyPI 0.1.2
- Added better Error handling for calls to Powerwall with debug info for timeout and connection errors.
- Added timestamp stats to pypowerwall proxy server.py (via URI /stats and /stats/clear)
pyPowerwall Debug
DEBUG:pypowerwall [0.1.2]
DEBUG:loaded auth from cache file .powerwall
DEBUG:Starting new HTTPS connection (1): 10.0.1.2:443
DEBUG:ERROR Timeout waiting for Powerwall API https://10.0.1.2/api/devices/vitals
Proxy Stats
{"pypowerwall": "0.1.2", "gets": 2, "errors": 3, "uri": {"/stats": 1, "/soe": 1}, "ts": 1641148636, "start": 1641148618, "clear": 1641148618}
- PyPI 0.1.1
- Added stats to pypowerwall proxy server.py (via URI /stats and /stats/clear)
- Added Information Functions:
site_name()
,version()
,din()
,uptime()
, andstatus()
.
# Display System Info
print("Site Name: %s - Firmware: %s - DIN: %s" % (pw.site_name(), pw.version(), pw.din()))
print("System Uptime: %s\n" % pw.uptime())
- PyPI 0.1.0
- Added protobuf handling to support decoding the Powerwall Device Vitals data (requires protobuf package)
- Added function
vitals()
to pull Powerwall Device Vitals - Added function
strings()
to pull data on solar panel strings (Voltage, Current, Power and State)
vitals = pw.vitals(jsonformat=False)
strings = pw.strings(jsonformat=False, verbose=False)
- PyPI 0.0.3
- Added Proxy Server - Useful for metrics gathering tools like telegraf (see proxy]).
- Added Powerwall Simulator - Mimics Powerwall Gateway responses for testing (see pwsimulator])
- Added raw binary poll capability to be able to pull protobuf formatted payloads like '/api/devices/vitals'.
payload = pw.poll('/api/devices/vitals')
- PyPI 0.0.2
- pyPowerwall now has a network scan function to find the IP address of Powerwalls
# Scan Network for Powerwalls
python -m pypowerwall scan
Output Example:
pyPowerwall Network Scanner [0.0.2]
Scan local network for Tesla Powerwall Gateways
Your network appears to be: 10.0.3.0/24
Enter Network or press enter to use 10.0.3.0/24:
Running Scan...
Host: 10.0.3.22 ... OPEN - Not a Powerwall
Host: 10.0.3.45 ... OPEN - Found Powerwall 1234567-00-E--TG123456789ABC
Done
Discovered 1 Powerwall Gateway
10.0.1.45 [1234567-00-E--TG123456789ABC]
- PyPI 0.0.1
- Initial Beta Release 0.0.1