Normalize electricity pricing factors#3377
Open
LKuemmel wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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 |
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.
openWB/openwb-ui-settings#980