Skip to content

Add retry to GECloud write#3860

Merged
springfall2008 merged 1 commit intomainfrom
fix/ge_cloud_write_retry
May 4, 2026
Merged

Add retry to GECloud write#3860
springfall2008 merged 1 commit intomainfrom
fix/ge_cloud_write_retry

Conversation

@springfall2008
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings May 4, 2026 11:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves reliability of GECloud Direct inverter setting writes by retrying when the cloud API reports transient “timeout”-style error codes, and updates the test suite accordingly. It also bumps the Predbat version and enhances the GECloud Direct CLI test helper to support writing a specific entity/value from the command line.

Changes:

  • Add retry logic in GECloudDirect.async_write_inverter_setting() when the API returns transient error value codes.
  • Update GECloud write tests to validate successful writes include a non-error value, and add a new test covering retries on timeout code -1.
  • Extend the GECloud Direct CLI test helper to optionally write a specific entity/value; bump THIS_VERSION.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
apps/predbat/gecloud.py Adds retry-on-error-code handling for write responses; extends the CLI test helper with optional write support.
apps/predbat/tests/test_ge_cloud.py Updates write success expectations and adds a retry/fail test for timeout error-code responses.
apps/predbat/predbat.py Version bump from v8.37.7 to v8.37.8.

Comment thread apps/predbat/gecloud.py
if data_value in [-1, -2, -5, -6]:
data = None
# Inverter timeout, try to spread requests out
await asyncio.sleep(random.random() * (3 + retry))
Comment thread apps/predbat/gecloud.py
Comment on lines 1936 to 1940
parser = argparse.ArgumentParser(description="Test GECloud Direct API")
parser.add_argument("--api-key", required=True, help="GECloud Direct API key")
parser.add_argument("--write-entity", default=None, help="Entity ID to write (e.g. number.predbat_gecloud_SA1234_battery_charge_power)")
parser.add_argument("--write-value", default=None, help="Value to write to the entity")

Comment on lines +1928 to +1930
if call_count[0] != 10:
print("ERROR: Expected 10 retry attempts for error value code, got {}".format(call_count[0]))
return 1
@springfall2008 springfall2008 merged commit 1a71c83 into main May 4, 2026
5 checks passed
@springfall2008 springfall2008 deleted the fix/ge_cloud_write_retry branch May 4, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants