Skip to content

Commit

Permalink
Merge pull request #78 from emptywee/0.8.x/post
Browse files Browse the repository at this point in the history
v0.8.1 - Set battery reserve, operation mode
  • Loading branch information
jasonacox authored Apr 5, 2024
2 parents c7d070f + c7252ac commit 00f823f
Show file tree
Hide file tree
Showing 21 changed files with 957 additions and 220 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/pwsim-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: pwsim-docker

# Only trigger if a push is made to the pwsimulator folder
on:
push:
paths:
- 'pwsimulator/**'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: pwsimulator/
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/pwsimulator:latest
2 changes: 1 addition & 1 deletion .github/workflows/simtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

services:
simulator:
image: jasonacox/pwsimulator
image: ${{ github.repository_owner }}/pwsimulator
ports:
- 443:443

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,5 @@ proxy/teslapy
.fleetapi*

.idea
**/.cachefile
.cachefile
56 changes: 54 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ and call function to poll data. Here is an example:
Functions
poll(api, json, force) # Return data from Powerwall api (dict if json=True, bypass cache force=True)
post(api, payload, json) # Send payload to Powerwall api (dict if json=True)
level() # Return battery power level percentage
power() # Return power data returned as dictionary
site(verbose) # Return site sensor data (W or raw JSON if verbose=True)
Expand All @@ -167,7 +168,12 @@ and call function to poll data. Here is an example:
# - "numeric": -1 (Syncing), 0 (DOWN), 1 (UP)
is_connected() # Returns True if able to connect to Powerwall
get_reserve(scale) # Get Battery Reserve Percentage
get_mode() # Get Current Battery Operation Mode
set_reserve(level) # Set Battery Reserve Percentage (only cloud mode)
set_mode(mode) # Set Current Battery Operation Mode (only cloud mode)
get_time_remaining() # Get the backup time remaining on the battery
set_operation(level, mode, json) # Set Battery Reserve Percentage and/or Operation Mode
```

Expand All @@ -181,10 +187,27 @@ The following are some useful tools based on pypowerwall:

* [Powerwall Dashboard](https://github.com/jasonacox/Powerwall-Dashboard#powerwall-dashboard) - Monitoring Dashboard for the Tesla Powerwall using Grafana, InfluxDB, Telegraf and pyPowerwall.

## Powerwall Scanner
## Powerwall Command Line

pyPowerwall has a built in feature to scan your network for available Powerwall gateways and set/get operational and reserve modes.

```
Usage: PyPowerwall [-h] {setup,scan,set,get,version} ...
PyPowerwall Module v0.8.1
pyPowerwall has a built in feature to scan your network for available Powerwall gateways. This will help you find the IP address of your Powerwall.
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
```

```bash
# Install pyPowerwall if you haven't already
python -m pip install pypowerwall
Expand Down Expand Up @@ -212,6 +235,35 @@ Discovered 1 Powerwall Gateway
10.0.1.36 [1232100-00-E--TG123456789ABG]
```

Get Power Levels, Operation Mode, and Battery Reserve Level

```bash
# Setup Connection with Tesla Cloud
python -m pypowerwall setup

# Get Power Levels, Operation Mode, and Battery Reserve Setting
#
# Usage: PyPowerwall get [-h] [-format FORMAT]
# -h, --help show this help message and exit
# -format FORMAT Output format: text, json, csv
#
python -m pypowerwall get
python -m pypowerwall get -format json
python -m pypowerwall get -format csv

# Set Operation Mode and Battery Reserve Setting
#
# Usage: PyPowerwall set [-h] [-mode MODE] [-reserve RESERVE] [-current]
# -h, --help show this help message and exit
# -mode MODE Powerwall Mode: self_consumption, backup, or autonomous
# -reserve RESERVE Set Battery Reserve Level [Default=20]
# -current Set Battery Reserve Level to Current Charge
#
python -m pypowerwall set -mode self_consumption
python -m pypowerwall set -reserve 30
python -m pypowerwall set -current
```

## Example API Calls

The following APIs are a result of help from other projects as well as my own investigation.
Expand Down
33 changes: 29 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
# RELEASE NOTES

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

* 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.
* 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
```

## v0.8.0 - Refactoring

* Refactored pyPowerwall by @emptywee in https://github.com/jasonacox/pypowerwall/pull/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.
* 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.

## v0.7.12 - Cachefile, Alerts & Strings
Expand Down
Loading

0 comments on commit 00f823f

Please sign in to comment.