Skip to content

charging price calculation: energy * price for equal prices - #3688

Merged
LKuemmel merged 1 commit into
openWB:masterfrom
LKuemmel:price_calc
Jul 21, 2026
Merged

LKuemmel merged 1 commit into
openWB:masterfrom
LKuemmel:price_calc

Conversation

@LKuemmel

@LKuemmel LKuemmel commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Ticket #66000952

Gleiche Preise

  • Aktualisierung während der Ladung im 5 Minuten Intervall
  • Berechnung am Ende der Ladung

Unterschiedliche Preise

  • Aktualisierung während der Ladung im 5 Minuten Intervall
  • Berechnung am Ende der Ladung

Dyn. Strompreis

  • Aktualisierung während der Ladung im 5 Minuten Intervall
  • Berechnung am Ende der Ladung

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adjusts how charging costs are calculated when all configured energy-source prices are identical and electricity pricing is not configured (Ticket #66000952), aiming to simplify the calculation to “energy * price” in that scenario.

Changes:

  • Added a dedicated “one-price” calculation path for the equal-prices scenario in calc_energy_costs.
  • Refactored the existing cost calculation into _calc_energy_costs_source_price.
  • Updated/extended unit tests to cover the new branching behavior.

Reviewed changes

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

File Description
packages/control/chargelog/chargelog.py Adds equal-price shortcut path and splits cost calculation into one-price vs. source-price helpers.
packages/control/chargelog/chargelog_test.py Updates tests for refactor and adds new tests for one-price path and branch coverage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/control/chargelog/chargelog.py Outdated
Comment on lines +327 to +334
def calc_energy_costs(cp, create_log_entry: bool = False):
prices = data.data.general_data.data.prices
if (prices.bat == prices.cp == prices.grid == prices.pv and
data.data.optional_data.data.electricity_pricing.configured is False):
if create_log_entry:
_calc_energy_costs_one_price(cp)
else:
_calc_energy_costs_source_price(cp, create_log_entry)
Comment on lines +155 to +160
def test_calc_energy_costs_one_price(mock_data):
cp = Chargepoint(4, None)
cp.data.set.log.imported_since_mode_switch = 3950
prices = data.data.general_data.data.prices
prices.bat = 0.3

Comment on lines +161 to +163
_calc_energy_costs_one_price(cp)

assert cp.data.set.log.costs == 1185
Comment on lines +169 to +171
(True, False, True, 1, 0),
(True, False, False, 0, 0),
(True, True, True, 0, 1),
@LKuemmel
LKuemmel merged commit 41af81a into openWB:master Jul 21, 2026
1 check passed
@LKuemmel
LKuemmel deleted the price_calc branch July 21, 2026 08:25
ndrsnhs pushed a commit to ndrsnhs/core that referenced this pull request Aug 24, 2026
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