Skip to content

Commit

Permalink
Merge pull request #157 from vincentwolsink/fix_nonetype
Browse files Browse the repository at this point in the history
FIX: object has no attribute 'status_code' #156
  • Loading branch information
vincentwolsink authored Sep 23, 2024
2 parents a6506dd + e5496d0 commit 9bfba59
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions custom_components/enphase_envoy/envoy_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def __init__(self, reader):

def set_endpoint_data(self, endpoint, response):
"""Called by EnvoyReader.update_endpoints when a response is successfull"""
if response.status_code > 400:
if response.status_code != 200:
# It is a server error, do not store endpoint_data
return

Expand Down Expand Up @@ -770,8 +770,6 @@ async def _async_fetch_with_retry(self, url, **kwargs):
received_401 += 1
continue
_LOGGER.debug("Fetched from %s: %s: %s", url, resp, resp.text)
if resp.status_code != 200:
return None
return resp
except httpx.TransportError as e:
_LOGGER.debug("TransportError: %s", e)
Expand Down Expand Up @@ -1105,8 +1103,8 @@ async def update_endpoints(self, endpoints=None):
time.time() - endpoint_settings["last_fetch"],
)

if self.data:
self.data.set_endpoint_data(endpoint, getattr(self, endpoint))
if self.data:
self.data.set_endpoint_data(endpoint, getattr(self, endpoint))

async def get_data(self, get_inverters=True):
"""
Expand Down

0 comments on commit 9bfba59

Please sign in to comment.