Skip to content

Commit

Permalink
fix: Reverted partial request fulfillment
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Jul 31, 2024
1 parent c5fd9b1 commit 7a2fca9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions custom_components/solarman/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ async def async_get(self, runtime = 0):
params = ParameterParser(self.parameter_definition)
requests = params.get_requests(runtime)
requests_count = len(requests)
results = [0] * requests_count
results = [1] * requests_count

_LOGGER.debug(f"Scheduling {requests_count} query requests. #{runtime}")

Expand All @@ -240,7 +240,7 @@ async def async_get(self, runtime = 0):
_LOGGER.debug(f"Querying ({start} - {end}) ...")

attempts_left = ACTION_ATTEMPTS
while attempts_left > 0:
while attempts_left > 0 and results[i] == 0:
attempts_left -= 1

try:
Expand All @@ -256,13 +256,10 @@ async def async_get(self, runtime = 0):

_LOGGER.debug(f"Querying {'succeeded.' if results[i] == 1 else f'attempts left: {attempts_left}{'' if attempts_left > 0 else ', aborting.'}'}")

if results[i] == 1:
break

if not 1 in results and results[i] == 0:
if results[i] == 0:
break

if 1 in results:
if not 0 in results:
return self.get_result(params)
else:
await self.async_get_failed(f"Querying {self.serial} at {self.address}:{self.port} failed.")
Expand Down

0 comments on commit 7a2fca9

Please sign in to comment.