Skip to content

Commit

Permalink
Merge branch 'v0.10.8' of https://github.com/jasonacox/pypowerwall in…
Browse files Browse the repository at this point in the history
…to v0.10.8
  • Loading branch information
jasonacox committed Jul 7, 2024
2 parents b2c362d + 68bb702 commit 6c50bdf
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
12 changes: 12 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
* Add TEDAPI `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()`)
* Add TEDAPI `get_components()` and `get_battery_block()` functions which providing 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 (TODO).

## v0.10.7 - Energy History

* FleetAPI - Add `get_history()` and `get_calendar_history()` to return energy, power, soe, and other history data.

```python
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")
```

## v0.10.6 - pyLint Cleanup

* Minor Bug Fixes - TEDAPI get_reserve() fix to address unscaled results.
Expand Down
34 changes: 34 additions & 0 deletions pypowerwall/fleetapi/fleetapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
get_site_info() - get site info
get_battery_reserve() - get battery reserve level
get_operating_mode() - get operating mode
get_history() - get energy history
get_calendar_history() - get calendar history
solar_power() - get solar power
grid_power() - get grid power
battery_power() - get battery power
Expand Down Expand Up @@ -462,6 +464,38 @@ def get_products(self, force=False):
log.debug(f"get_products: {payload}")
return self.keyval(payload, "response")

def get_calendar_history(self, kind=None, duration=None, time_zone=None,
start=None, end=None):
""" Get energy history
kind: power, soe, energy, backup, self_consumption,
time_of_use_energy, savings
duration: day, week, month, year, lifetime
time_zone: America/Los_Angeles
start: 2024-05-01T00:00:00-07:00 (RFC3339 format)
end: 2024-05-01T23:59:59-07:00
"""
return self.get_history(kind, duration, time_zone,
start, end, "calendar_history")

def get_history(self, kind=None, duration=None, time_zone=None,
start=None, end=None, history="history"):
""" Get energy history
kind: power, energy, backup, self_consumption
duration: day, week, month, year, lifetime
time_zone: America/Los_Angeles
start: 2024-05-01T00:00:00-07:00 (RFC3339 format)
end: 2024-05-01T23:59:59-07:00
"""
if not self.site_id:
return None
arg_kind = f"kind={kind}&" if kind else ""
arg_duration = f"period={duration}&" if duration else ""
arg_time_zone = f"time_zone={time_zone}" if time_zone else ""
arg_start = f"start={start}&" if start else ""
arg_end = f"end={end}&" if end else ""
h = self.poll(f"api/1/energy_sites/{self.site_id}/{history}?{arg_kind}{arg_duration}{arg_time_zone}{arg_start}{arg_end}")
return self.keyval(h, "response")

def set_battery_reserve(self, reserve: int):
if reserve < 0 or reserve > 100:
log.debug(f"Invalid reserve level: {reserve}")
Expand Down

0 comments on commit 6c50bdf

Please sign in to comment.