Skip to content

Default logic: Charge rate optimization#188

Merged
MaStr merged 2 commits intomainfrom
charging-optimization
Sep 24, 2025
Merged

Default logic: Charge rate optimization#188
MaStr merged 2 commits intomainfrom
charging-optimization

Conversation

@MaStr
Copy link
Owner

@MaStr MaStr commented Sep 24, 2025

  • honor battery limits
  • only calculate needed recharge energy if charging is possible
  • add some tests

@MaStr MaStr added this to the 0.5.3 milestone Sep 24, 2025
@MaStr MaStr requested a review from Copilot September 24, 2025 14:44
@MaStr MaStr self-assigned this Sep 24, 2025
@MaStr MaStr added the enhancement New feature or request label Sep 24, 2025
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

Optimizes charge rate calculation logic by honoring battery limits and improving energy calculation efficiency. The changes only calculate required recharge energy when charging is actually possible, preventing unnecessary computations when the battery is at or above charging limits.

  • Only calculate required recharge energy when charging is possible based on SOC limits
  • Limit required recharge energy to available charging capacity
  • Add comprehensive test coverage for charging scenarios and edge cases

Reviewed Changes

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

File Description
src/batcontrol/logic/default.py Optimizes charging logic to respect battery limits and calculate recharge energy conditionally
tests/batcontrol/logic/test_default.py Adds comprehensive test cases for charging scenarios, SOC limits, and error handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

def test_charge_calculation_when_charging_not_possible_high_soc(self):
"""Test charge calculation when charging is not possible due to high SOC"""
# Set SOC above charging limit (79%)
stored_energy = 8000 # 8.0 kWh, above charging limit of 7.9 kWh
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

Remove trailing whitespace after the comment.

Suggested change
stored_energy = 8000 # 8.0 kWh, above charging limit of 7.9 kWh
stored_energy = 8000 # 8.0 kWh, above charging limit of 7.9 kWh

Copilot uses AI. Check for mistakes.
@MaStr MaStr merged commit 62f16ba into main Sep 24, 2025
10 checks passed
@MaStr MaStr deleted the charging-optimization branch September 24, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants