Skip to content

Commit

Permalink
fix #50: don't try to parse json response if content is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
jrester committed Aug 17, 2023
1 parent 003f4a4 commit 525281b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tesla_powerwall/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ def _process_response(self, response: requests.Response) -> dict:
# API returned some sort of error that must be handled
self._handle_error(response)

if len(response.content) == 0:
return {}

try:
response_json = response.json()
except JSONDecodeError:
Expand Down Expand Up @@ -225,6 +228,12 @@ def get_logs(self):
def get_meters(self) -> list:
return self.get("meters")

def get_meters_site(self) -> list:
return self.get("meters/site")

def get_meters_solar(self) -> list:
return self.get("meters/solar")

def get_installer(self) -> dict:
return self.get("installer")

Expand Down

0 comments on commit 525281b

Please sign in to comment.