jasonacox / pypowerwall

Python API for Tesla Powerwall and Solar Power Data
MIT License
134 stars 24 forks source link

v0.10.0 - New Device Vitals #95

Closed jasonacox closed 4 months ago

jasonacox commented 4 months ago

Device Vitals via TEDAPI

Updates

Coding Examples

# 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")

Related Issues and Discussions:

jasonacox commented 4 months ago

Nice to see the Alert and Island voltage/frequency data back:

image

Discovered problem with POD_nom_energy_remaining and POD_nom_full_pack_energy data and also added a computed POD_nom_energy_to_be_charged.

Nice to see the String data and Powerwall Capacity data back.

image
jasonacox commented 4 months ago

Getting close to ready to release. I have tested local mode (with and without TEDAPI), cloud mode and fleetAPI mode.

How to test using Powerwall-Dashboard

First, you need to set up the host that will run your Dashboard to have a route to your Powerwall Gateway. This varies based on the OS, but will be something like this:

# Change 10.x.x.x to the address of your Powerwall on your LAN
sudo ip route add 192.168.91.0/24 via 10.x.x.x

# Note: This is a temporary route. To make it survive a reboot, you need to set it in the system
# or add it to something like /etc/rc.local 

Edit the powerwall.yml file and replace the image name for pypowerwall to jasonacox/pypowerwall:0.10.0t58-beta7 like this:

...
    pypowerwall:
        image: jasonacox/pypowerwall:0.10.0t58-beta7
        container_name: pypowerwall
        hostname: pypowerwall
        restart: unless-stopped
...

Edit pypowerwall.env and edit the IP address and add the PW_GW_PWD setting:

PW_HOST=192.168.91.1
PW_GW_PWD="GW_PASSWORD"

Apply the changes using:

./compose-dash.sh up -d

# and to tail the logs... ^C to quit
docker logs pypowerwall -f
jasonacox commented 4 months ago

Latest: jasonacox/pypowerwall:0.10.0t58-beta9