Add retry to GECloud write#3860
Merged
springfall2008 merged 1 commit intomainfrom May 4, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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. |
| 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 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.