From cbf49426fc4e2cbc766adcb305cc8ea11f7fbcfe Mon Sep 17 00:00:00 2001 From: Ramesh Motaparthy Date: Sat, 7 Sep 2024 21:23:16 +0000 Subject: [PATCH 1/3] Check if activeAlerts exists before listing alerts --- tools/tedapi/PW3_Strings.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/tedapi/PW3_Strings.py b/tools/tedapi/PW3_Strings.py index ab32a5c..3d586de 100644 --- a/tools/tedapi/PW3_Strings.py +++ b/tools/tedapi/PW3_Strings.py @@ -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 'activeAlerts' in 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 """ From a4ab9ca772974eb4fcba4022fcd978a06c587361 Mon Sep 17 00:00:00 2001 From: Ramesh Motaparthy Date: Sat, 7 Sep 2024 21:51:28 +0000 Subject: [PATCH 2/3] fix the if statement --- tools/tedapi/PW3_Strings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tedapi/PW3_Strings.py b/tools/tedapi/PW3_Strings.py index 3d586de..09ba0f4 100644 --- a/tools/tedapi/PW3_Strings.py +++ b/tools/tedapi/PW3_Strings.py @@ -179,7 +179,7 @@ print(f" - Alerts:") components = data['components'] for component in components: - if 'activeAlerts' in components[component]: + if components[component]: for alert in components[component][0]['activeAlerts']: if alert['name'] not in alerts: alerts.append(alert['name']) From e9582fa3b0238cec342ca0d8019d0e8de2095248 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sat, 7 Sep 2024 15:59:52 -0700 Subject: [PATCH 3/3] v0.11.1 prep --- RELEASE.md | 5 +++++ proxy/requirements.txt | 2 +- pypowerwall/__init__.py | 2 +- pypowerwall/fleetapi/pypowerwall_fleetapi.py | 9 +++++---- pypowerwall/tedapi/__init__.py | 7 ++++--- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 96ec1b1..a68376f 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -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. diff --git a/proxy/requirements.txt b/proxy/requirements.txt index ee9e6c3..d6275eb 100644 --- a/proxy/requirements.txt +++ b/proxy/requirements.txt @@ -1,2 +1,2 @@ -pypowerwall==0.11.0 +pypowerwall==0.11.1 bs4==0.0.2 diff --git a/pypowerwall/__init__.py b/pypowerwall/__init__.py index a5b08d0..7c0ff5e 100644 --- a/pypowerwall/__init__.py +++ b/pypowerwall/__init__.py @@ -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' diff --git a/pypowerwall/fleetapi/pypowerwall_fleetapi.py b/pypowerwall/fleetapi/pypowerwall_fleetapi.py index 091cab3..60ae0ce 100644 --- a/pypowerwall/fleetapi/pypowerwall_fleetapi.py +++ b/pypowerwall/fleetapi/pypowerwall_fleetapi.py @@ -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 diff --git a/pypowerwall/tedapi/__init__.py b/pypowerwall/tedapi/__init__.py index d9735b5..579b5aa 100644 --- a/pypowerwall/tedapi/__init__.py +++ b/pypowerwall/tedapi/__init__.py @@ -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