You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In trying to get pypowerwall to use the fleet API I experienced several errors that I've tracked down.
When pypowerwall calls /api/1/products it returns both a car and power product for me like below (shorted and redacted). Because the car details do not contain a key energy_site_id, code that assumes this key exists throws a KeyError exception, and never gets to check sites[1] so an additional check is needed for that.
Also, I noticed that in trying to get the setup completed through some hacking, the site_id in .pypowerwall.fleetapi was stored as a string, not a number. This causes comparison checks to fail given the API for products returns energy_site_id as a number.
Once I changed site_id in .pypowerwall.fleetapi to be a number and added a key check, it worked as expected.
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 @@ class PyPowerwallFleetAPI(PyPowerwallBase):
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
The text was updated successfully, but these errors were encountered:
Great find @gregrahn !!! Wow, that is bad. I don't have a car, so my tests were passing. Would you be willing to submit a PR? I want you to get credit for this great work.
In trying to get pypowerwall to use the fleet API I experienced several errors that I've tracked down.
When pypowerwall calls
/api/1/products
it returns both a car and power product for me like below (shorted and redacted). Because the car details do not contain a keyenergy_site_id
, code that assumes this key exists throws a KeyError exception, and never gets to checksites[1]
so an additional check is needed for that.Also, I noticed that in trying to get the setup completed through some hacking, the
site_id
in.pypowerwall.fleetapi
was stored as a string, not a number. This causes comparison checks to fail given the API for products returnsenergy_site_id
as a number.Once I changed
site_id
in.pypowerwall.fleetapi
to be a number and added a key check, it worked as expected.Shorted
/api/1/products
response:Key check
The text was updated successfully, but these errors were encountered: