Skip to content

Commit

Permalink
Merge pull request #76 from jasonacox/solar_powerwall
Browse files Browse the repository at this point in the history
Use solar_powerwall for string data
  • Loading branch information
jasonacox authored Mar 18, 2024
2 parents 58e685b + e95fc14 commit 7e8753d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# RELEASE NOTES

## v0.7.12 - Cachefile and Alerts
## v0.7.12 - Cachefile, Alerts & Strings

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

Expand Down
22 changes: 22 additions & 0 deletions pypowerwall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,28 @@ def strings(self, jsonformat=False, verbose=False):
# for
deviceidx += 1
# else
# If no devices found pull from /api/solar_powerwall
if not v:
# Build a string map: A, B, C, D, A1, B2, etc.
string_map = []
for number in ['','1','2','3','4','5','6','7','8']:
for letter in ['A','B','C','D']:
string_map.append(letter + number)
payload = self.poll('/api/solar_powerwall', jsonformat=True) or {}
if payload and 'pvac_status' in payload:
# Strings are in PVAC status section
pvac = payload['pvac_status']
if 'string_vitals' in pvac:
i = 0
for string in pvac['string_vitals']:
name = string_map[i]
result[name] = {}
result[name]['Connected'] = string['connected']
result[name]['Voltage'] = string['measured_voltage']
result[name]['Current'] = string['current']
result[name]['Power'] = string['measured_power']
i += 1
# Return result
if (jsonformat):
json_out = json.dumps(result, indent=4, sort_keys=True)
return json_out
Expand Down
3 changes: 3 additions & 0 deletions pypowerwall/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,9 @@ def poll(self, api):
elif api == '/api/troubleshooting/problems':
data = json.loads('{"problems":[]}')

elif api == '/api/solar_powerwall':
data = json.loads('{}')

else:
data = {"ERROR": f"Unknown API: {api}"}

Expand Down

0 comments on commit 7e8753d

Please sign in to comment.