Skip to content

Normalize electricity pricing factors - #3377

Merged
LKuemmel merged 5 commits into
openWB:masterfrom
LKuemmel:normalize_electricity_pricing_factors
Jun 9, 2026
Merged

LKuemmel merged 5 commits into
openWB:masterfrom
LKuemmel:normalize_electricity_pricing_factors

Conversation

@LKuemmel

Copy link
Copy Markdown
Contributor

@LKuemmel
LKuemmel requested a review from Copilot May 20, 2026 11:56
@LKuemmel LKuemmel added this to the 2.2.1 milestone May 20, 2026

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 updates electricity tariff handling to use consistent, normalized price units across providers and ensures existing persisted configurations are migrated accordingly. It also aligns tariff summation logic with the current configuration object structure (config.configuration.*).

Changes:

  • Normalize EnergyCharts surcharge handling to add a surcharge already expressed in €/Wh.
  • Remove the runtime scaling in the FixedHours tariff provider so it emits the configured value directly.
  • Add datastore migration (version 124) to convert legacy tariff/surcharge configuration values into the normalized units and adjust grid-fee/tariff store access paths.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/modules/electricity_pricing/flexible_tariffs/fixed_hours/tariff.py Removes runtime division/scaling when emitting FixedHours prices.
packages/modules/electricity_pricing/flexible_tariffs/fixed_hours/tariff_test.py Updates expectations to match new FixedHours output behavior.
packages/modules/electricity_pricing/flexible_tariffs/energycharts/tariff.py Updates price conversion to add surcharge directly (expects surcharge in €/Wh).
packages/modules/common/store/_tariff.py Reads default_price / includes_grid_fee from config.configuration.*.
packages/modules/common/store/_tariff_test.py Adjusts mocks to match the updated configuration shape.
packages/helpermodules/update_config.py Bumps datastore version and adds migration logic for normalized pricing units.
packages/helpermodules/update_config_test.py Adds tests covering the new datastore migration behavior and idempotency.

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

Comment on lines 69 to +71
time_slot = current_hour + datetime.timedelta(hours=i, minutes=j * 15)
epoch_time = int(time.mktime(time_slot.timetuple()))
prices[str(epoch_time)] = _fetch_price_for_time_slot(config, time_slot) / AS_EURO_PER_WH
prices[str(epoch_time)] = _fetch_price_for_time_slot(config, time_slot)
@@ -27,7 +27,7 @@ def create_request_url(config: EnergyChartsTariffConfiguration) -> str:
def parse_response(config: EnergyChartsTariffConfiguration, raw_prices: dict) -> Dict[str, float]:
prices: Dict[int, float] = {}
self._append_datastore_version(123)

def upgrade_datastore_124(self) -> None:
def upgrade(topic: str, payload) -> None:
provider = decode_payload(payload)
if provider["type"] == "energycharts":
surcharge = provider["configuration"]["surcharge"]
if surcharge > 0.1: # entspricht mehr als 0.1ct/kWh konfiguriertem Zuschlag
Comment on lines +208 to 209
assert isinstance(price, (float, int))
assert price == expected_price
@LKuemmel
LKuemmel force-pushed the normalize_electricity_pricing_factors branch from 5d5cb15 to 3bc48af Compare June 9, 2026 09:25
@LKuemmel
LKuemmel merged commit 3ddce58 into openWB:master Jun 9, 2026
1 check passed
@LKuemmel
LKuemmel deleted the normalize_electricity_pricing_factors branch June 9, 2026 09:39
ndrsnhs pushed a commit to ndrsnhs/core that referenced this pull request Aug 24, 2026
* electricity pricing: normalize pricing factors to €/Wh

* fix pytest

* fix pytest

* review

* fix pytest
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