Skip to content

Commit

Permalink
Update proxy for v0.12.3 and add /csv/v2 API support
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonacox committed Jan 21, 2025
1 parent 88c93c7 commit ed6ede2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
9 changes: 9 additions & 0 deletions proxy/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## pyPowerwall Proxy Release Notes

### Proxy t68 (20 Jan 2025)

* pyPowerwall v0.12.3 - Adds Custom GW IP for TEDAPI.
* Add new API /csv/v2 which extends /csv by adding grids status (1/0) and battery reserve (%)setting:

```python
# Grid,Home,Solar,Battery,Battery_Level,Grid_Status,Reserve
```

### Proxy t67 (26 Dec 2024)

* pyPowerwall v0.12.2 - Fix bug in cache timeout code that was not honoring pwcacheexpire setting. Raised by @erikgiesele in https://github.com/jasonacox/pypowerwall/issues/122 - PW_CACHE_EXPIRE=0 not possible? (Proxy)
Expand Down
2 changes: 1 addition & 1 deletion proxy/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pypowerwall==0.12.2
pypowerwall==0.12.3
bs4==0.0.2
18 changes: 13 additions & 5 deletions proxy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import pypowerwall
from pypowerwall import parse_version

BUILD = "t67"
BUILD = "t68"
ALLOWLIST = [
'/api/status', '/api/site_info/site_name', '/api/meters/site',
'/api/meters/solar', '/api/sitemaster', '/api/powerwalls',
Expand Down Expand Up @@ -369,8 +369,9 @@ def do_GET(self):
elif self.path == '/api/system_status/grid_status':
# Grid Status - JSON
message: str = pw.poll('/api/system_status/grid_status', jsonformat=True)
elif self.path == '/csv':
# Grid,Home,Solar,Battery,Level - CSV
elif self.path == '/csv' or self.path == '/csv/v2':
# CSV Output - Grid,Home,Solar,Battery,Level
# CSV2 Output - Grid,Home,Solar,Battery,Level,GridStatus,Reserve
contenttype = 'text/plain; charset=utf-8'
batterylevel = pw.level() or 0
grid = pw.grid() or 0
Expand All @@ -381,8 +382,15 @@ def do_GET(self):
solar = 0
# Shift energy from solar to load
home -= solar
message = "%0.2f,%0.2f,%0.2f,%0.2f,%0.2f\n" \
% (grid, home, solar, battery, batterylevel)
if self.path == '/csv':
message = "%0.2f,%0.2f,%0.2f,%0.2f,%0.2f\n" \
% (grid, home, solar, battery, batterylevel)
else:
gridstatus = 1 if pw.grid_status() == 'UP' else 0
reserve = pw.get_reserve() or 0
message = "%0.2f,%0.2f,%0.2f,%0.2f,%0.2f,%d,%d\n" \
% (grid, home, solar, battery, batterylevel,
gridstatus, reserve)
elif self.path == '/vitals':
# Vitals Data - JSON
message: str = pw.vitals(jsonformat=True) or json.dumps({})
Expand Down

0 comments on commit ed6ede2

Please sign in to comment.