Skip to content

Commit

Permalink
Merge pull request #112 from rmotapar/fix-index-out-of-range-in-pw3-s…
Browse files Browse the repository at this point in the history
…trings

Check if activeAlerts exists before listing alerts
  • Loading branch information
jasonacox authored Sep 7, 2024
2 parents 1edec5c + e9582fa commit 458ba68
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
5 changes: 5 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# RELEASE NOTES

## v0.11.1 - PW3 and FleetAPI Bugfix

* TEDAPI: Fix bug with activeAlerts logic causing errors on systems with multiple Powerwall 3's. Identified by @rmotapar in https://github.com/jasonacox/Powerwall-Dashboard/issues/387#issuecomment-2336431741
* FleetAPI: Fix connect() to handle non-energy products in the getsites response. Identified by @gregrahn in https://github.com/jasonacox/pypowerwall/issues/111

## v0.11.0 - Add PW3 Vitals

* Add polling of Powerwall 3 Devices to pull in PW3 specific string data, capacity, voltages, frequencies, and alerts.
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.11.0
pypowerwall==0.11.1
bs4==0.0.2
2 changes: 1 addition & 1 deletion pypowerwall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
from typing import Union, Optional
import time

version_tuple = (0, 11, 0)
version_tuple = (0, 11, 1)
version = __version__ = '%d.%d.%d' % version_tuple
__author__ = 'jasonacox'

Expand Down
9 changes: 5 additions & 4 deletions pypowerwall/fleetapi/pypowerwall_fleetapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,11 @@ def connect(self):
else:
found = False
for idx, site in enumerate(sites):
if site['energy_site_id'] == self.siteid:
self.siteindex = idx
found = True
break
if 'energy_site_id' in site:
if site['energy_site_id'] == self.siteid:
self.siteindex = idx
found = True
break
if not found:
log.error("Site %r not found for %s" % (self.siteid, self.email))
return False
Expand Down
7 changes: 4 additions & 3 deletions pypowerwall/tedapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,10 @@ def get_pw3_vitals(self, force=False):
alerts = []
components = data['components']
for component in components:
for alert in components[component][0]['activeAlerts']:
if alert['name'] not in alerts:
alerts.append(alert['name'])
if components[component]:
for alert in components[component][0]['activeAlerts']:
if alert['name'] not in alerts:
alerts.append(alert['name'])
bms_component = data['components']['bms'][0] # TODO: Process all BMS components
signals = bms_component['signals']
nom_energy_remaining = 0
Expand Down
9 changes: 5 additions & 4 deletions tools/tedapi/PW3_Strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@
print(f" - Alerts:")
components = data['components']
for component in components:
for alert in components[component][0]['activeAlerts']:
if alert['name'] not in alerts:
alerts.append(alert['name'])
print(f" - Alert: {alert['name']}")
if components[component]:
for alert in components[component][0]['activeAlerts']:
if alert['name'] not in alerts:
alerts.append(alert['name'])
print(f" - Alert: {alert['name']}")

# Pull out nominal full pack energy and energy remaining
"""
Expand Down

0 comments on commit 458ba68

Please sign in to comment.