Skip to content

Minor tidy up on inverter retry/waits#2619

Merged
springfall2008 merged 2 commits intomainfrom
fixes5
Aug 17, 2025
Merged

Minor tidy up on inverter retry/waits#2619
springfall2008 merged 2 commits intomainfrom
fixes5

Conversation

@springfall2008
Copy link
Owner

No description provided.

@springfall2008 springfall2008 requested a review from Copilot August 17, 2025 15:34
Copy link
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 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_RETRY and INVERTER_MAX_RETRY_REST in 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)
Copy link

Copilot AI Aug 17, 2025

Choose a reason for hiding this comment

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

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)

Copilot uses AI. Check for mistakes.
@springfall2008 springfall2008 merged commit 840f94d into main Aug 17, 2025
1 check passed
@springfall2008 springfall2008 deleted the fixes5 branch August 17, 2025 15:37
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.

1 participant