Skip to content

Energy-Charts: Börsenpreisobergrenze ergänzt - #4284

Merged
LKuemmel merged 1 commit into
openWB:masterfrom
LKuemmel:electricity_tariff
Nov 9, 2026
Merged

LKuemmel merged 1 commit into
openWB:masterfrom
LKuemmel:electricity_tariff

Conversation

@LKuemmel

@LKuemmel LKuemmel commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Ticket #66010050
UI openWB/openwb-ui-settings#1165

Summary by Sourcery

Add an optional exchange-price cap for Energy-Charts tariffs and migrate existing configurations to the new setting.

New Features:

  • Add an optional price cap for Energy-Charts electricity prices before surcharges and taxes are applied.

Enhancements:

  • Extend Energy-Charts tariff configuration and pricing behavior to support the optional cap.

Tests:

  • Add coverage for datastore migration scenarios, including existing caps and non-Energy-Charts providers.

Chores:

  • Migrate existing Energy-Charts provider configurations to include the new optional price cap and advance the datastore version.

@LKuemmel
LKuemmel requested a review from ndrsnhs November 9, 2026 10:00
@sourcery-ai

sourcery-ai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Schema and migrations

Bump the datastore version and migrate existing Energy-Charts provider configurations to include the optional price_cap field.

  • packages/helpermodules/update_config.py L66, L4194-4208

Data structures

Add the optional price_cap field to the Energy-Charts tariff configuration structure.

  • packages/modules/electricity_pricing/flexible_tariffs/energycharts/config.py L2, L11

Implementation

Apply the configured price cap to the raw Energy-Charts price before adding the surcharge and calculating tax.

  • packages/modules/electricity_pricing/flexible_tariffs/energycharts/tariff.py L30-33

Tests

Test datastore migration behavior for Energy-Charts configurations with and without an existing price cap, as well as other providers.

  • packages/helpermodules/update_config_test.py L637-668

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/helpermodules/update_config.py" line_range="4208" />
<code_context>
+            return None
+
+        self._loop_all_received_topics(upgrade)
+        self._append_datastore_version(156)
</code_context>
<issue_to_address>
**Failed migration is marked complete**

When the retained provider payload has not arrived, decoding fails, or an Energy-Charts payload has a missing or null configuration, `_loop_all_received_topics` leaves the provider unmigrated, but `upgrade_datastore_156` still calls `_append_datastore_version(156)`, so later startups skip the migration and the configuration stays incomplete.

Only append datastore version 156 after confirming the provider migration completed successfully.

Also at `packages/helpermodules/update_config.py:4201`, `packages/helpermodules/update_config.py:4207`.
</issue_to_address>

### Comment 2
<location path="packages/helpermodules/update_config_test.py" line_range="666-667" />
<code_context>
+        assert json.loads(uc.all_received_topics[topic]) == {
+            "type": provider_type, "configuration": expected_configuration
+        }
+    updated_topics = [call.args[0] for call in mock_pub.pub.call_args_list]
+    assert (topic in updated_topics) is updated
+    assert uc.all_received_topics["openWB/system/datastore_version"] == [155, 156]
</code_context>
<issue_to_address>
**Wrong migration payload goes unnoticed**

When `Pub.pub` receives a payload different from the migrated provider configuration, `test_upgrade_datastore_156_adds_energycharts_price_cap` extracts only `call.args[0]` at line 666 and checks only the topic at line 667, so it passes when `Pub.pub` publishes an incorrect payload for that topic. The migration can therefore publish the wrong provider configuration without this test detecting it.

Assert that the publication for the provider topic carries the expected migrated configuration.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

return None

self._loop_all_received_topics(upgrade)
self._append_datastore_version(156)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Failed migration is marked complete

When the retained provider payload has not arrived, decoding fails, or an Energy-Charts payload has a missing or null configuration, _loop_all_received_topics leaves the provider unmigrated, but upgrade_datastore_156 still calls _append_datastore_version(156), so later startups skip the migration and the configuration stays incomplete.

Only append datastore version 156 after confirming the provider migration completed successfully.

Also at packages/helpermodules/update_config.py:4201, packages/helpermodules/update_config.py:4207.

Prompt for AI agents
In `packages/helpermodules/update_config.py` at line 4208:

**Failed migration is marked complete**

When the retained provider payload has not arrived, decoding fails, or an Energy-Charts payload has a missing or null configuration, `_loop_all_received_topics` leaves the provider unmigrated, but `upgrade_datastore_156` still calls `_append_datastore_version(156)`, so later startups skip the migration and the configuration stays incomplete.

Only append datastore version 156 after confirming the provider migration completed successfully.

Also at `packages/helpermodules/update_config.py:4201`, `packages/helpermodules/update_config.py:4207`.

Comment on lines +666 to +667
updated_topics = [call.args[0] for call in mock_pub.pub.call_args_list]
assert (topic in updated_topics) is updated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Wrong migration payload goes unnoticed

When Pub.pub receives a payload different from the migrated provider configuration, test_upgrade_datastore_156_adds_energycharts_price_cap extracts only call.args[0] at line 666 and checks only the topic at line 667, so it passes when Pub.pub publishes an incorrect payload for that topic. The migration can therefore publish the wrong provider configuration without this test detecting it.

Assert that the publication for the provider topic carries the expected migrated configuration.

Prompt for AI agents
In `packages/helpermodules/update_config_test.py` at lines 666-667:

**Wrong migration payload goes unnoticed**

When `Pub.pub` receives a payload different from the migrated provider configuration, `test_upgrade_datastore_156_adds_energycharts_price_cap` extracts only `call.args[0]` at line 666 and checks only the topic at line 667, so it passes when `Pub.pub` publishes an incorrect payload for that topic. The migration can therefore publish the wrong provider configuration without this test detecting it.

Assert that the publication for the provider topic carries the expected migrated configuration.

@LKuemmel
LKuemmel merged commit 155c4d4 into openWB:master Nov 9, 2026
2 checks passed
buhito81 added a commit to buhito81/core that referenced this pull request Nov 10, 2026
upgrade_datastore_156 is now the Energy-Charts price cap (openWB#4284); the weekdays repair moves to 157.
buhito81 added a commit to buhito81/core that referenced this pull request Nov 10, 2026
upgrade_datastore_156 is now the Energy-Charts price cap (openWB#4284); data_tariff_split moves to 157.
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