Minor tidy up on inverter retry/waits#2619
Merged
springfall2008 merged 2 commits intomainfrom Aug 17, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR standardizes and makes configurable the retry logic for inverter commands by replacing hardcoded retry values with named constants. The changes improve maintainability by centralizing retry configuration and making it easier to adjust retry behavior across the codebase.
- Introduces configurable constants
INVERTER_MAX_RETRYandINVERTER_MAX_RETRY_RESTin config.py - Replaces hardcoded retry values (5, 6, 8) with the new constants throughout inverter.py
- Updates unit tests to use the configurable retry count for generating expected command sequences
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/predbat/config.py | Adds two new constants for configuring inverter retry limits |
| apps/predbat/inverter.py | Replaces hardcoded retry values with configurable constants and adds consistent sleep delays |
| apps/predbat/unit_test.py | Updates test to dynamically generate expected commands based on configurable retry count |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| self.count_register_writes += 1 | ||
| self.base.log("Inverter {} charge target {} via REST successful on retry {}".format(self.id, target, retry)) | ||
| return True | ||
| self.sleep(2) |
There was a problem hiding this comment.
The sleep duration of 2 seconds is hardcoded. Consider making this configurable as a constant like the retry values to maintain consistency with the PR's goal of eliminating magic numbers.
Suggested change
| self.sleep(2) | |
| self.sleep(INVERTER_REST_SLEEP_SECONDS) |
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.