Skip to content

Ladeprotokoll: Energie und Kosten je Tarifzeitraum (Feste Tarifstunden) - #4117

Open
buhito81 wants to merge 10 commits into
openWB:masterfrom
buhito81:feature_chargelog_tariff_split
Open

buhito81 wants to merge 10 commits into
openWB:masterfrom
buhito81:feature_chargelog_tariff_split

Conversation

@buhito81

@buhito81 buhito81 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Umsetzung von #4111. Oberfläche: openWB/openwb-ui-settings#1129

Ladeprotokoll: Energie (Zähler des Ladepunkts) und Kosten je Zeitfenster der Festen Tarifstunden, z. B. „NT: 18,40 kWh / 4,73 €". Opt-in (Spalte standardmäßig aus, upgrade_datastore_158), dynamische Tarife unverändert.

  • Laden nur im Standardpreis
  • Laden über einen Tarifwechsel (Summe der Zeitfenster = data.costs)
  • Lademoduswechsel (Zwischeneintrag setzt die Aufteilung zurück)
  • dynamischer Tarif / kein Preismodul: kein tariff_split, Eintrag unverändert
  • alte Einträge ohne Schlüssel: Summen und CSV bleiben gültig
  • CSV-Export: zwei Spalten je Zeitfenster am Ende

Getestet per pytest, nicht auf einer Box.

… Netzanteil

Die Aufteilung je Tarifzeitraum enthält jetzt die gesamte geladene Energie des
Intervalls (über alle Quellen) und seine Kosten, wie sie in costs eingehen. Die
Kosten je Tarifzeitraum ergeben so in Summe data.costs. CSV-Spalten heißen
"Energie <Name>" / "Kosten <Name>".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@buhito81 buhito81 changed the title Ladeprotokoll: Netzbezug und Kosten je Tarifzeitraum (Feste Tarifstunden) Ladeprotokoll: Energie und Kosten je Tarifzeitraum (Feste Tarifstunden) Oct 15, 2026
Ohne Tarifzeitraum (dynamische Tarife, kein Preismodul, Rückfallpfad) bleibt
der Preis-Eintrag im Tageslog unverändert.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
buhito81 and others added 4 commits October 20, 2026 11:55
Konflikt in packages/control/optional_test.py mit openWB#3782 (PV-Prognose):
beide Seiten ergänzen Importe und Tests, beide behalten.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
openWB#4110 hat create_entry nach process_log_entry_builder.py verschoben: die
tariff_name-Zeilen stehen jetzt dort, write_log.py übernimmt die master-Seite.
chargelog_test.py: beide Seiten behalten, dazu ein Test, dass das
angebrochene letzte Intervall den Tarifzeitraum der aktuellen Messung bekommt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
master took datastore version 155 (obsolete prio fields); the tariff-split
column default moves to upgrade_datastore_156.
@buhito81
buhito81 marked this pull request as ready for review November 3, 2026 15:28
upgrade_datastore_156 is now the Energy-Charts price cap (openWB#4284); data_tariff_split moves to 157.
@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Schema and migrations

Add a datastore upgrade that opts the new tariff-split log column out by default while preserving any existing user setting, and advance the datastore version.

  • packages/helpermodules/update_config.py L66, L4190-4201

Data structures

Add tariff-period energy and cost totals to the charge-log state so charge-log calculation and entry creation can persist the split.

  • packages/control/chargepoint/chargepoint_data.py L101-102

API

Expose a tariff-period name for the same price timeslot, returning no name when fixed tariff hours do not apply.

  • packages/modules/electricity_pricing/flexible_tariffs/fixed_hours/tariff.py L5-10, L70-72, L77-103

Include tariff-period names in daily price records only when the price module provides one, leaving fallback and dynamic-tariff records unchanged.

  • packages/helpermodules/measurement_logging/process_log_entry_builder.py L57-61, L67-68
  • packages/helpermodules/measurement_logging/write_log.py L29

Uses of the API

Use the current fixed-hours tariff name when accumulating interval energy and costs, and include a rounded tariff split in charge-log entries when one exists.

  • packages/control/chargelog/chargelog.py L59-61, L305-307, L351-352

Aggregate tariff-split values across filtered charge-log entries while continuing to tolerate records without the new field.

  • packages/control/chargelog/process_chargelog.py L4, L115, L122-141

Implementation

Resolve the tariff-period label for the first current-price timeslot only when all configured pricing modules use fixed tariff hours.

  • packages/control/optional.py L21, L26, L225-242

Assign each positive-energy interval and its calculated cost to its tariff, and extract rounded splits from accumulated log state.

  • packages/control/chargelog/chargelog.py L357-375

Introduce an optional tariff-split column in the charge-log column defaults.

  • packages/helpermodules/measurement_logging/process_log.py L33

Add datastore migration coverage for the default-hidden tariff-split column and preservation of an existing preference.

  • packages/helpermodules/update_config_test.py L707-724

UI

Append energy and cost CSV columns for each tariff period found in charge-log entries, leaving blanks where an entry has no matching split.

  • web/settings/downloadChargeLog.php L166-181, L186-195, L249-253

Tests

Test tariff-name lookup for fixed-hours, default-price, missing configuration fields, and consistency with the matching price.

  • packages/modules/electricity_pricing/flexible_tariffs/fixed_hours/tariff_test.py L11-13, L396-462

Test optional-module tariff-name resolution for fixed-hour combinations and cases where a tariff name is unavailable.

  • packages/control/optional_test.py L1, L7-8, L505-566

Cover charge-log tariff accumulation across tariff changes, current-entry assignment, absent tariff names, serialization, and reset behavior.

  • packages/control/chargelog/chargelog_test.py L11, L281-388

Test totals aggregation with mixed legacy and split entries, including malformed split data and the no-split case.

  • packages/control/chargelog/process_chargelog_test.py L1-30

Test that daily price entries include a tariff name only when a price is available and the tariff module returns a name.

  • packages/helpermodules/measurement_logging/write_log_test.py L4-6, L11, L173-197

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

…ariff_split

# Conflicts:
#	packages/helpermodules/update_config.py
…ariff_split

# Conflicts:
#	packages/helpermodules/update_config_test.py
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.

1 participant